当前位置:网站首页>'utf-8' codec can't decode byte 0xb9 in position 0: invalid start byte
'utf-8' codec can't decode byte 0xb9 in position 0: invalid start byte
2022-08-07 12:02:00 【Chenchen who loves learning net security】
The code implements emailing:
#Header package is used to process the basic information of mail (sender, receiver, mail header)from email.header import Header#MIMETextMessage text contentfrom email.mime.text import MIMEText#The toolkit for sending emailsfrom email.utils import parseaddr,formataddrimport smtplibdef title(s):print(s)name,addr = parseaddr(s)return formataddr((Header(name, 'utf-8').encode(), addr))#senderfromAddr = 'Send Email'#Authorization codepassword = 'authorization code'#receivertoAddr = 'Accept Email'#protocol serverserver = 'smtp.163.com'port = 25#mail bodymsg = MIMEText('Send the red envelope~~~', 'plain', 'utf-8')# msg = MIMEText('message', 'plain', 'utf-8')#mail titlemsg['Subject'] = Header('Pink Girl Warrior', 'utf-8').encode()#mail sender nicknamemsg['From'] = title('LaLaLa<%s>' % fromAddr)#mail recipient nicknamemsg['To'] = title('<%s>' % toAddr)server = smtplib.SMTP(server, port)server.login(fromAddr, password)server.sendmail(fromAddr, [toAddr], msg.as_string())server.quit() #Remember to closeError reporting method:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 0: invalid start byteReason: Unicode encoding format is not uniform.
The solution is:
The computer name cannot be Chinese. Change your computer name to English and restart the computer.
边栏推荐
猜你喜欢

Interpretation of Gin-based Go language project network disk

CCNP-第十九篇-ISIS(二)

质量、重力和重量

地图加柱状图、饼图组合可视化

pyautogui practice - 10 lines of code to realize the "solidified desktop" in "Broken Elite"

If you want to learn a language, you need many previous knowledge points

As the complexity of the model increases, how is overfitting caused?How to solve?

柠檬班unitest和数据驱动

Qt QImage 图像处理(翻转,灰度,亮度)代码实现

The difference between delete commands in MySQL (delete, truncate, drop)
随机推荐
The use and brief principle of xxl-job
高级课程作业zabbix01
中国石油大学(北京)-《钻井液工艺原理》第二阶段在线作业
精进型全栈工程师应牢记的工程优先级顺序
搭一个K3S 玩玩
pyautogui practice - 10 lines of code to realize the "solidified desktop" in "Broken Elite"
关于#mysql#的问题:如图创建以上表格,报错代码如下SELECT * FROM studentwhere 姓名 LIKE可%
WPF 实现更换主题色
What is the Office Open XML file format
Flutter packaging
ie浏览器的部分兼容性问题
小心!正则 test() 匹配的一个“坑”
分享幸福(2)
Advanced coursework zabbix01
flutter打包
封装、继承和多态
[Microservice Architecture] Distributed Current Limiting Strategy
PAT 刷题笔记
UGUI Series - Implementing Hierarchical Menus (Unity3D)
xxl-job的使用及简述原理