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

posted @ 2020-10-18 17:42  Penny悦  阅读(11649)  评论(0编辑  收藏  举报