在写python的小爬虫的时候,发现一个小问题,就是显示编码错误
只要在python代码开头加一句#-*- coding: UTF-8 -*-
就可以了
#!/user/bin/python #-*- coding: UTF-8 -*- import urllib2 respoese=urllib2.urlopen('https://www.baidu.com/?tn=94733117_hao_pg') print str(respoese.getcode())+'输出信息'