标签:with pytho typeerror python close body blog 方式 bytes
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()
TypeError: write() argument must be str, not bytes
标签:with pytho typeerror python close body blog 方式 bytes
原文地址:http://www.cnblogs.com/AndyChen2015/p/7493332.html