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