HTTPリクエスト

POSTでファイル送信

import requests

str_data1 = '12345678'
str_data2 = 'abcdefgh'
file_path = 'C:\\path\\to\\file1.png'

url = 'http://192.168.33.10/example.php'
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