[英]How can I print all unicode characters?
for i in range(1000,1100):
s=unicode('u'+str(i))
print i,s
使用unichr :
s = unichr(i)
從文檔中:
unichr(i)
返回其 Unicode 代碼為整數 i 的一個字符的 Unicode 字符串。 例如,unichr(97) 返回字符串 u'a'。
嘗試以下操作:
for i in range(1000, 1100):
print i, unichr(i)
unichr
是您正在尋找的函數 - 它接受一個數字並返回該點的 Unicode 字符。
for i in range(1000, 1100):
print i, unichr(i)
(Python 3)以下將為您提供與任意 unicode 范圍相對應的字符
start_code, stop_code = '4E00', '9FFF' # (CJK Unified Ideographs)
start_idx, stop_idx = [int(code, 16) for code in (start_code, stop_code)] # from hexadecimal to unicode code point
characters = []
for unicode_idx in range(start_idx, stop_idx+1):
characters.append(chr(unicode_idx))
使用chr
而不是unichr
以避免出現錯誤消息。
for i in range(1000, 1100):
print i, chr(i)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.