欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-04-14 09:31:21
...

在Python3中

mail.Subject = sub.decode('utf-8')

报错如下:

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

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

修改为

mail.Subject = sub.encode('utf-8').decode('utf-8')