requests 学习笔记

除了get 方式外 还有post 等等

注意字典里值为 None 的键都不会被添加到 URL 的查询字符串里

import requests

getpara = {"key1":"value1","keu2":"value2"}
r = requests.get('https://api.github.com/events',params=getpara)

print(r.url)

#r.url = https://api.github.com/events?key1=value1&keu2=value2

r.url  查看URL

r.text 查看响应内容

r.encoding = ‘utf8’    更改编码格式(影响后面的编码)

猜你喜欢

转载自www.cnblogs.com/echoboy/p/9296903.html