AttributeError: 'list' object has no attribute 'decode'


在用python群發郵件時報錯:AttributeError: 'list' object has no attribute 'decode'

這是因為 Header 接收的第一個參數的類型只能是字符串或者字節

解決方式:
使用 join() 函數,將列表中字符串使用某種字符串連接,形式——str.join(list) ,示例:

a = ['abc','123','xyz789']
b = ','
c =b.join(a)
print(c)
print(type(c)

參考博文:https://blog.csdn.net/weixin_42422090/article/details/104535526


免責聲明!

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



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