url请求

使用内置urllib:

import urllib.request, urllib.parse, urllib.error

fhand = urllib.request.urlopen('http://data.pr4e.org/romeo.txt')
for line in fhand:
    print(line.decode().strip())

 

第三方类库requests:

https://requests.readthedocs.io/

 

posted @ 2022-06-12 15:39  zhishaofei3  阅读(29)  评论(0编辑  收藏  举报