如何比较2个文件并生成匹配列表,获取值错误?
选择 | 换行 | 行号
- f = open("Desktop/MEME_IDS", "r") #open file with list of terms to search for
- patterns = {} #create an open dictionary (this is a string)
- while True:
- line = f.readline() #read each line of file1, put into variable line
- if (line == ''): #at the end of file, stop
- break
- patterns[line] = None #put each line into a list with the key patterns
- f = open("Desktop/genelistAFUA.txt", "r") #open next file
- while True:
- line = f.readline() #read each line in, with break for end of file, as above
- if (line == ''):
- break
- col1, col2 = line.split("\t") #split the file into 2 columns, that are separated by a tab, what I want to match is in col1, info i need is in col2
- if (col1 in patterns): # if the value in col1 matches the patterns list above, then print col2
- print col2
#从A到从全基因组列表解析我感兴趣的基因的子列表
#FORMAT OF FILE 1是一个简单的单值列表,第二个文件有2列,我正在匹配来自文件1的列表中的列1。
#我的错误是:
回溯(最近一次呼叫):
文件"Desktop/parsefile.py",第14行,位于
Col1,col2=line.plit("\t")#将文件拆分为两列,用制表符分隔
ValueError:需要多个值才能解包
有什么想法吗?