- 增加或改变已打开文件的编码
import urllib.requestimport iou = urllib.request.urlopen('http://www.python.org')f = io.TextIOWrapper(u, encoding='utf-8')text = f.read()print(text)import sysprint(sys.stdout.encoding)sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='latin-1')print(sys.stdout.encoding)