网络编程
import urllib.request as request
url = "https://v.api.aa1.cn/api/pyq/index.php"
req = request.Request(url)
with request.urlopen(req) as response:
data = response.read().decode()
print(data)
json
- load 将文件数据转为python对象
- loads 将内存数据转换为python对象
json.load(open('file.json','r'))
- dump 将dict转换为json字符串保存到文件中
- dumps 将dict转换为json字符串