【发布时间】:2017-07-06 11:04:12
【问题描述】:
我正在尝试将包含 2 个浮点数和 3 个文本部分的元组转换为一个字符串,以便我可以在 file.write() 中使用它,因为它不接受元组。
testr = 'you went' ,speed ,'mph and stopped in' ,stop ,'meters'
test = open('testresults.txt' ,'w')
test.write(testr)
test.close()
每当我尝试运行程序时,它都会给我这个
test.write(testr)
TypeError: must be str, not tuple
【问题讨论】: