我有一个看起来像这样的文本文件:
01:Pronoun
02:I
03:We
04:Self
05:You
06:Other
07:Negate
08:Assent
09:Article
10:Preps
11:Number
12:Affect
...
现在我想制作一本这样的字典。一个看起来像这样的字典:
{'01:': ['pronoun'], '02': ['I'],...}
这是我到目前为止的代码,但它似乎不像我想要的那样工作......
with open ('LIWC_categories.text','rU') as document1:
categoriesLIWC = {}
for line in document1:
line = line.split()
if not line:
continue
categoriesLIWC[line[0]] = line[1:]