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"
多说一句吧。发邮件的时候,邮箱本身会进行一些限制,要学会查看错误手册!
转载请注明原文地址:https://ipadbbs.8miu.com/read-5800.html