1. 首页
  2. 数据库
  3. 其它
  4. Python txt文件加入字典并查询的方法

Python txt文件加入字典并查询的方法

上传者: 2021-01-01 02:48:36上传 PDF文件 29.53KB 热度 17次
如下所示: dicFile = open('train_1.txt', 'r')#打开数据 print '开始装载数据...' txtDict = {}#建立字典 while True: line = dicFile.readline() if line == '': break index = line.find('\t')#以tab键为分割 key = line[:index] value = line[index:] txtDict[key] = value#加入字典 dicFi
下载地址
用户评论