Chinese and Japanese character support in python

后端 未结 3 1735
执笔经年
执笔经年 2020-12-06 02:53

How to read correctly japanese and chinese characters. I\'m using python 2.5. Output is displayed as \"E:\\Test\\?????????\"

path = r\"E:\\Test\         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 03:31

    You should force the string to be a unicode object like

    path = ur"E:\Test\は最高のプログラマ"
    

    Docs on string literals relevant to 2.5 are located here

    Edit: I'm not positive on if the object is a unicode in 2.5 but the docs do state that \uXXXX[XXXX] will be processed and the the string will be "a Unicode string".

提交回复
热议问题