【发布时间】:2021-07-26 00:32:32
【问题描述】:
我有一个文本文件 config.txt,其中的数据格式如下。每个键值都在一个新行中。 值是一个字符串列表。
key_inv_single = ['invoice']
key_inv_number = ['invoice number', 'invoice no', 'invoice #', 'invoice#']
key_inv_date = ['invoice date', 'invoice dt', 'issue date', 'date of invoice', 'date of issue', 'issue dt', 'dt of issue']
我想把它反序列化成一个与文件同名的python字典。
{
key_inv_single : ['invoice']
key_inv_number : ['invoice number', 'invoice no', 'invoice #', 'invoice#']
key_inv_date : ['invoice date', 'invoice dt', 'issue date', 'date of invoice', 'date of issue', 'issue dt', 'dt of issue']
}
【问题讨论】:
-
嗨!请在您的帖子中添加您的尝试,stackoverflow.com/help/how-to-ask
标签: python list dictionary text deserialization