我正在尝试在 webob.Response 中返回二进制文件,但发生错误
file = open(filePath, 'rb')
buffer = file.read()
file.close()
self._response.body = buffer
提供回溯
"F:\Program Files\Python32\python.exe" G:/development/projects/AutoBlog/main.py
Traceback (most recent call last):
File "F:\Program Files\Python32\lib\wsgiref\handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "G:/development/projects/AutoBlog/main.py", line 30, in application
print(wsgiApplication)
File "F:\Program Files\Python32\lib\site-packages\webob\response.py", line 218, in __str__
parts += ['', self.text if PY3 else self.body]
File "F:\Program Files\Python32\lib\site-packages\webob\response.py", line 383, in _text__get
return body.decode(self.charset, self.unicode_errors)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
activate.adobe.com - - [20/May/2012 14:52:49] "GET /res/images/i.jpg HTTP/1.1" 500 59