如何从字典分裂元组如何分割元组在Python
dic = {('K30', 'K56'): 1}
得到这个输出的文本文件:
K30 K56 1
是我的尝试是
for k,v in dic.items():
a,b = k.split(',')
print >>f, a+'\t',b+'\t',v
f.close()
但我得到了错误:
AttributeError: 'tuple' object has no attribute 'split'
或'为(A,B), v in dic.items():' –