我的代码的最小工作示例:
# Create output data file
out_data_file = open('output_file','w')
out_data_file.write("# Header \n")
out_data_file.close()
list1 = [1,3,4,5,12,6,2,35,74,6,2]
# Open file to append
with open('output_file', "a") as f:
f.write('Text'+' '+str(['%d' % item for item in list1]))
这给了我一个output_file
看起来像:
# Header
Text ['1', '3', '4', '5', '12', '6', '2', '35', '74', '6', '2']
我希望输出看起来像这样:
# Header
Text 1 3 4 5 12 6 2 35 74 6 2
我怎样才能做到这一点?