通过Python 2.7在.xls上写多个列

out_file.write('Position'+'\t'+'Hydrophobic'+'\n') for i in position: out_file.write(str(i)+'\n') for j in value: out_file.write('\t'+str(j)+'\n') 

所以它说

 Position Hydrophobic 0 a 1 b 2 c #... and so on 

当它写入到excel文件时,它把它放在位置列的i列的底部

我怎么把它们放在'\ t'和'\ n'旁边?

 for i, j in zip(position, value): out_file.write(str(i) + '\t' + str(j) + '\n') 

或更好:

  out_file.write('%s\t%s\n' % (str(i), str(j)) 

或更好:

 text = ['%s\t%s' % (str(i), str(j) for i, j in zip(position, value)] text = '\n'.join(text) out_file.write(text)