HTTPリクエスト

POSTでファイル送信

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import requests
 
str_data1 = '12345678'
str_data2 = 'abcdefgh'
file_path = 'C:\\path\\to\\file1.png'
 
data = {'str_data1': str_data1, 'str_data2': str_data2}
file = {'file': open(file_path, 'rb')}
 
res = requests.post(url, files=file, data=data)
 
print(res)
print(res.text)

programming/python/tips/http_request.txt · 最終更新: 2018/04/13 by ikatakos
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0