展开折叠字段
dic={(‘bar’, ‘one’): [1], (‘bar’, ‘three’): [3], (‘bar’, ‘two’): [5], (‘foo’, ‘one’): [0, 6], (‘foo’, ‘three’): [7], (‘foo’, ‘two’): [2, 4]}
lst=[] for k,v in dic.items():
for va in v: #print(va) #new=ka.append(va) ##append(不能直接用等号的!!!!) ka=list(k) ka.append(va) lst.append(ka) #print(new)print(lst)
折叠字段 list1=[]#save tissue type and mean of RPKM dict1={}#Tissue type and RPKM
f=open(“CTCF.csv”,“r”) lines=f.readlines() for L in lines[1:]: line=L.strip() sep_line=line.split(",") if sep_line[1] not in dict1:
dict1[sep_line[1]]=[] dict1[sep_line[1]].append(sep_line[2]) else: dict1[sep_line[1]].append(sep_line[2])f.close()