在使用POST提交數(shù)據(jù)時,想實現(xiàn)下面這種情況:
requests.post(url, data={'interests':'football','interests':'basketball'})用這種方式肯定是錯誤的,因為字典中的key是唯一的。
使用元組列表 代碼如下:
import requestsurl = 'http://httpbin.org/post'r = requests.post(url, data=[('interests', 'football'), ('interests', 'basketball')])r.json()['form']新聞熱點
疑難解答