python编程,排除163邮箱发送邮件报错(AttributeError: ‘tuple‘ object has no attribute ‘encode‘)

python编程学习,排除163邮箱发送邮件报错(AttributeError: ‘tuple’ object has no attribute ‘encode’

AttributeError: 'tuple' object has no attribute 'encode'

根据提示初步判断跟类型或者编码有关。

在网上查找到了第一种解决方案:

使用join方法解决,确实有效。

to_addr = ["xxxxxxxxx@163.com", "xxxxxxxxx@qq.com"]
msg['To'] = ','.join(to_addr)

通过打印生成结果,思考第二种解决途径:

直接输入***一整个字符串 ***,中间以逗号分割。经测试成功发送。

msg['To'] = "xxxxxxxxx@163.com, xxxxxxxxx@qq.com"

多说一句吧。发邮件的时候,邮箱本身会进行一些限制,要学会查看错误手册!


版权声明:本文为qq_40674586原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。