How to display chinese character in 65001 in python? -
i in win7 +python3.3.
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'
how can display chinese character 你
in 65001?
if terminal capable of displaying character directly (which may not due font issues) should work(tm).
>>> hex(65001) >>> u"\ufde9" '\ufde9' >>> print(u"\ufde9")
to avoid use of literals, note in python 3, @ least, chr()
function take code point , return associated unicode character. works too, avoiding need hex conversions.
>>> print(chr(65001))
Comments
Post a Comment