我想從網站獲取圖像,但我不知道自己做錯了什麼。 這是我的代碼:試圖用python獲取圖像
import httplib2
h = httplib2.Http('.cache')
response, content = h.request('http://1.bp.blogspot.com/-KSBzFF0bIyU/TtFyj-KgC0I/AAAAAAAABEo/o43IoY_9Bec/s1600/praia-de-ponta-verde-maceio.jpg')
print(response.status)
with open('maceio.jpg', 'wb') as f:
print(content, file = f)
--------------------------------------------------------------------------------
200
Traceback (most recent call last):
File "/home/matheus/workspace/Get Link/new_method_v2.py", line 12, in <module>
print(content, file = f)
TypeError: 'str' does not support the buffer interface
[類型錯誤:「STR」不支持緩衝器接口]的可能重複:(http://stackoverflow.com/questions/5471158/typeerror-str只使用
file.write()
方法寫內容到文件-does-not-support-the-buffer-interface) –