Python3和Python2的urllib的使用不同
1、python3中使用urllib.request
2、Python2中用的是urllib
egg:
import urllib.request # python3中必须用urllib.request Python2中用的是urllib
url = "http://www.gutenberg.org/files/2554/2554-0.txt"
raw = urllib.request.urlopen(url).read().decode("utf-8") # 必须用decode("utf-8")转码,不然输出的是byte格式的文字
3万+

被折叠的 条评论
为什么被折叠?



