私は既に多くのコードスニペットをチェックしましたが、Python 2.4のみでシングルリクエストでテキストとバイナリファイルの両方をマルチパートに投稿する方法が見つかりませんでしたか?コメントのHereは、BytesIOクラスについて言及しましたが、2.4では存在しません。 (プレーンなPython、サードパーティのライブラリはありません)ありがとうございました。ここにあなたがリクエスト・ライブラリを使用することができますPythonの2.6とマルチパートバイナリファイルPOST in python 2.4
1
A
答えて
0
は、documentationから抽出されたスニペットです:
>>> url = 'http://httpbin.org/post'
>>> files = {'report.xls': open('report.xls', 'rb')}
>>> r = requests.post(url, files=files)
>>> r.text
{
"origin": "179.13.100.4",
"files": {
"report.xls": "<censored...binary...data>"
},
"form": {},
"url": "http://httpbin.org/post",
"args": {},
"headers": {
"Content-Length": "3196",
"Accept-Encoding": "identity, deflate, compress, gzip",
"Accept": "*/*",
"User-Agent": "python-requests/0.8.0",
"Host": "httpbin.org:80",
"Content-Type": "multipart/form-data; boundary=127.0.0.1.502.21746.1321131593.786.1"
},
"data": ""
}
+0
リクエストのバージョンがPython 2.4をサポートしているかどうかはわかりません。 –
+0
うん、それはどんな依存関係もなしで行われるべきである。 – Oink
関連する問題
- 1. OpenCV 2.4 in python - ビデオ処理
- 2. Http POST Curl in Python
- 3. Python Cookbook for Python 2.4
- 4. Python 2.4 plistlib on
- 5. Python 2.4のrelativedelta
- 6. Python 2.4のSHA256ハッシュ
- 7. python 2.4のgoogle mod_pagespeed?
- 8. POST in rails 3
- 9. cfhttp "POST" in PHP
- 10. Python 2.4からPython 2.6への移行
- 11. Wordpress NextGen Slider in Post
- 12. JQuery Ajax POST in Codeigniter
- 13. @POST in RESTful Webサービス
- 14. OSError in os.wait in python
- 15. <a name=... in post form
- 16. HttpClient Multipart Form Post in C#
- 17. "URLパーツエラー" inetc :: post in nsis
- 18. Pythonのパス区切り文字2.4
- 19. パスワード認証なしのSendmail(Python 2.4)
- 20. Python 2.4でホームディレクトリパッケージがロードされない
- 21. PyGObject in Python 3 in windows
- 22. Python 2.6のバージョンをPython 2.5または2.4に変更
- 23. Python POSTリクエストのエンコーディング
- 24. Python POST ordered params
- 25. MemoryStream analog in Python
- 26. IBOutlet in Python
- 27. Heaps law in Python
- 28. webapp in python
- 29. crontab in python
- 30. sqlite3 in Python
あなたは[ポスター](http://atlee.ca/software/poster/)で見たことがありますか? – jterrace
サードパーティなしでこれを行う方法がない場合は、私はポスターのソースを掘り下げようとします。しかし、私はある種の回避策があることを願っています。 – Oink