我保证我在网上看过,但无法弄清楚在我的特定情况下该如何做。 我的数据在数组中:
box[0]
我想将其内容写入CSV文件。 我也在使用此功能来编写其他内容。
csv=open("newFile.csv", 'a+')
csv.write(time.strftime('%d/%m/%y')+','+time.strftime('%H:%M:%S') +','+ str(round(xnew))+','+ str(round(ynew))+','+box[0])
csv.write('\n')
csv.close()
在这种情况下,它无法写入任何内容,但是当我删除box [0]时,它确实会写入并且csv看起来像这样。
Date Time X Y
12/09/18 16:18:19 174 86
12/09/18 16:18:20 176 87
12/09/18 16:18:21 175 87
12/09/18 16:18:22 175 87
12/09/18 16:18:23 176 87
12/09/18 16:18:25 176 87
12/09/18 16:18:26 175 87
12/09/18 16:18:27 176 87
12/09/18 16:18:28 175 87
12/09/18 16:18:29 175 87
12/09/18 16:18:30 176 87
12/09/18 16:18:31 175 87
答案 0 :(得分:0)
我通过将box [0]更改为str(box [0])来解决了这个问题。
变化很小,但有时需要永远找出来。
谢谢