【Python】3.x 版本的print 乱码 问题

来源:互联网 发布:海康云台控制键盘网络 编辑:程序博客网 时间:2024/05/18 10:54

奇怪,之前发的博文中内容怎么没有了。最近刚开始用csdn,发现经常丢东西,不明白。。


import urllib.request url = 'http://www.baidu.com'  request = urllib.request.Request(url)response = urllib.request.urlopen(request)data = response.read()datautf = data.decode('UTF-8')fo = open('log.html', 'w',encoding='utf-8')fo.write(datautf)fo.close()text = open('log.html', encoding='utf8').read() print(text.encode('utf8'))


至此,Python3 中 print 问题解决。

原创粉丝点击