import json f = open("index.html", "wb") json.dump(response.data, f) f.close() dumps只完成了序列化为str, dump必须传文件描述符,将序列化的str保存到文件中