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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -