“TypeError:必须是str,而不是元组” 请问有人可以解释这个错误是什么?TypeError:必须是str,而不是tuple
0
A
回答
0
output_to_receipt是一个元组,因此您需要将其转换为带有str(output_to_receipt)或“”.join(output_to_receipt)的字符串,例如。
3
将receipt.write(output_to_receipt)
更改为receipt.write(str(output_to_receipt))
。
这将改变output_to_receipt
这是一个元组到字符串,你就可以写。
相关问题
- 1. TypeError:必须是字典,而不是str
- 2. Python - TypeError:字符串索引必须是整数,而不是str
- 3. 编码:TypeError:写入()参数必须是str,而不是字节
- 4. [python-3] TypeError:必须是str,而不是int
- 5. TypeError帮助:write()参数必须是str,而不是无
- 6. TypeError:元组索引必须是整数,而不是str
- 7. TypeError:必须是str,而不是int在python 3
- 8. TypeError:列表索引必须是整数,而不是str(Python)
- 9. builtins.TypeError:必须是str,而不是字节
- 10. TypeError:列表索引必须是整数,而不是来自JSON文件的str
- 11. TypeError:在调用函数时,必须是str,而不是Python 3中的列表
- 12. Python3 - TypeError:列表索引必须是整数或切片,而不是str - 列表
- 13. TypeError:列表索引必须是整数或切片,而不是str
- 14. Python,MongoDB,Mongoengine - TypeError:字符串索引必须是整数,而不是str
- 15. python:列表和字典,TypeError:列表索引必须是整数,而不是str
- 16. TypeError:字符串索引必须是整数,而不是str中的Python
- 17. 在Python3中,ElementTree TypeError“write()参数必须是str,而不是字节”
- 18. TypeError:无法将字节转换为str,然后TypeError:write()参数必须是str,而不是字节
- 19. write()参数必须是str,而不是字节
- 20. 列表索引必须是整数,而不是str
- 21. TypeError:write()参数必须是str,而不是字节,UTF-16
- 22. TypeError:JSON对象必须是str,而不是'bytes'
- 23. 错误:列表索引必须是indtegers,而不是str
- 24. 列表索引必须是整数,而不是str错误
- 25. Scrapy:TypeError:字符串索引必须是整数,而不是str?
- 26. 给出错误“JSON对象必须是str,而不是'字节'”
- 27. Django JSON Eroor:“列表索引必须是整数,而不是str”
- 28. TypeError:join()参数必须是str或bytes,而不是'NoneType'
- 29. TypeError:参数1必须是pygame.Surface,而不是方法
- 30. TypeError:列表索引必须是整数,而不是字典
对于哪一行打印错误? – bugmenot123
第27行:receipt.write(output_to_receipt) – rn01
它是一个元组。需要先将其转换为字符串 – Gogo