如下所示: 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