0
저는 win7 + python3.3에 있습니다.파이썬에서 65001로 중국어 문자를 표시하는 방법은 무엇입니까?
import os
os.system("chcp 936")
fh=open("test.ch","w",encoding="utf-8")
fh.write("你")
fh.close()
os.system("chcp 65001")
fh=open("test.ch","r",encoding="utf-8").read()
print(fh)
Äã
>>> print(fh.encode("utf-8"))
b'\xe4\xbd\xa0'
65001에 중국어 문자 你
을 어떻게 표시 할 수 있습니까?
나가서 설명하자면 NameError : >>> sys.stdout = io.TextIOWrapper (sys.stdout.detach(), 인코딩 = "UTF IO 이름 'IO'가 정의되지 – user1142618
>>> 가져 오기 SYS >>> (fh) >>> fh = open ("test.ch", "r", encoding = "utf-8") >>> print (fh.encode ("utf-8")) b '\ xe4 \ xbd \ xa0'문제가 남아 있습니다. – user1142618
python (명령 행)으로 python을 입력하면 문제가 해결됩니다. cmd로 python을 입력하고'python '을 입력해도 문제는 해결되지 않습니다. – user1142618