POST发送数据:
python# encoding:utf-8 import requests from StringIO import StringIO img = open('test.jpg').read() img = StringIO(img) files = {'img': img} baseUrl = r'http://localhost:8080/test' requests.post(baseUrl, files = files)
在web.py里
pythonimport web from PIL import Image urls = ('/test', 'Test') class Test: def GET(self): pass def POST(self): data = web.input() # 如何用PIL打开获取来的StringIO? img = Image.open(StringIO(data.img)) # 报错
线谢谢各位了。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
upload.py
main.py (儲存圖片到指定路徑並另存縮圖)
你得把报的具体错误贴上来。
不看错误内容就来问。。。有时候可能是个很简单的错误,比如在接收post过来的参数的时候data.files.img写成了data.img之类的