【待解決】python寫文件時報錯:TypeError: a bytes-like object is required, not 'str'


for i in ans:
        lst = []
        lst.append(i[0].encode())
        lst.append(i[1].encode())
        print (type(lst[0]))
        writer.writerow(lst[0])

這個,現在依舊很迷啊!!!

PS C:\Users\Desktop\database> python total.py
<class 'bytes'>
Traceback (most recent call last):
  File "total.py", line 38, in <module>
    writer.writerow(lst[0])
TypeError: a bytes-like object is required, not 'str'

lst[0]就是Bytes類型啊,咋還報這個錯?路過的大佬幫幫忙啊!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM