Python_异常:TypeError: write() argument must be str, not list
2021-05-19 18:28
标签:写入内容 open 字符串 img 处理 原因 type module src 文件写入操作时,报错:TypeError: write() argument must be str, not list 原因:python写入的内容要是字符串类型的 上代码: fp = open("a.txt","w") 写入内容为字符串类型则ok Python_异常:TypeError: write() argument must be str, not list 标签:写入内容 open 字符串 img 处理 原因 type module src 原文地址:https://www.cnblogs.com/rychh/p/9742203.html
fp.write([1,2,3])
fp.close()>>> fp = open("a.txt","w")
>>> fp.write([1,2,3])
Traceback (most recent call last):
File "
fp = open("a.txt","w")
fp.write(‘[1,2,3]‘)#将文件内容处理为字符串类型
fp.close()
文章标题:Python_异常:TypeError: write() argument must be str, not list
文章链接:http://soscw.com/index.php/essay/87726.html