python 将导入的txt文件存到dict里面
的有关信息介绍如下:# -*- coding: UTF-8 -*-__author__ = 'lpe234''''# tmp.txt斗魂,1恶魔少爷萝莉控,0官途,1医手遮天,1官途,1破窍九天,1天下师兄一般黑,0礼物:遇见于朦胧,0重生之锦绣嫡女,1先婚厚爱,0先婚厚爱,1'''def main(): tmp_dict = {} with open('tmp.txt', 'r') as f: txt = f.read() for t in txt.split(): k, v = t.split(',') if not k in tmp_dict: tmp_dict[k] = v print tmp_dictif __name__ == '__main__': main()