为了账号安全,请及时绑定邮箱和手机立即绑定

notepad++ 无论怎样配置中文都输出乱码

notepad++ 无论怎样配置中文都输出乱码

燕九3624187 2016-08-03 12:15:58
# -*- coding: utf-8 -*- import urllib2 import cookielib url = "http://www.baidu.com" print '方法1' response1 = urllib2.urlopen(url) print response1.getcode() print len(response1.read())   print '方法2' request= urllib2.Request(url) request.add_header("user-agent","Mozilla/5.0") response2 = urllib2.urlopen(url) print response2.getcode() print len(response2.read())   print '方法3' cj= cookielib.CookieJar() opener =urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) response3 = urllib2.urlopen(url) print response3.getcode() print cj print response3.read()到底该如何配置 才能使输出的中文 不是乱码 除了使用 print u'xxx'的方式。。如果使用print u'xxx'的方式 那么想输出倒数第二行的cj 内容的时候 如何让其内部的中文不输出为乱码呢?
查看完整描述

3 回答

?
慕莱坞9220042

TA贡献377条经验 获得超508个赞

你好,在格式里面有编码转换,你转成utf-8的试试看。

查看完整回答
反对 回复 2016-08-03
?
泥巴复苏OL

TA贡献1条经验 获得超0个赞

卸载重装

查看完整回答
反对 回复 2016-08-03
  • 3 回答
  • 0 关注
  • 10414 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信