w文件打开以 '二进制' 方式:
with open('teacher.html','wb+') as f: f.write(response.body)
要写入"中文",防止乱码:
fo = open("temp.txt", "wb+") str = '中文' str = str.encode('utf-8') fo.write(str) fo.close()