慕碼人8056858
2022-12-14 10:51:01
我有一個簡單的語法相關問題,如果有人能回答,我將不勝感激。所以我目前有字符串格式的字符標簽:'0941'。要在 Python 中打印出 unicode 字符,我可以使用以下命令:print(u'\u0941')現在,我的問題是如何將我擁有的標簽 ('0941') 轉換為 unicode 可讀格式 (u'\u0941')?太感謝了!
2 回答

慕田峪4524236
TA貢獻1875條經驗 獲得超5個贊
無需使用數字鍵盤即可完成此操作的一種方法是簡單地打印字符,然后將其復制/粘貼為標簽。
>>> print("lower case delta: \u03B4")
lower case delta: δ
>>> δ = 42 # copy the lower case delta symbol and paste it to use it as a label
>>> δδ = δ ** 2 # paste it twice to define another label.
>>> δ # at this point, they are just normal labels...
42
>>> δδ
1764
>>> δabc = 737 # using paste, it's just another character in a label
>>> δ123 = 456
>>> δabc, δ123 # exactly like any other alpha character.
(737, 456)
添加回答
舉報
0/150
提交
取消