[英]How to print the value of unicode character with unicodedata?
我正在嘗試在循環中打印 unicode 字符:
for i in range(0, 10):
unicodedata.normalize('NFKD', '\u00a{i}')
但這導致了下一個錯誤:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-4: truncated \uXXXX escape
然而想要的結果是:
¡
¢
£
¤
...
你有什么想法如何實施嗎?
只需使用chr(i)
(“返回表示其 Unicode 代碼點為整數i
的字符的字符串。”)而不是字符串格式的東西。
>>> for i in range(0, 10):
... print(chr(0xa0 + i))
...
¡
¢
£
¤
¥
¦
§
¨
©
>>>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.