テクノなまこ

科学の力

2023-09-01から1ヶ月間の記事一覧

pythonで、Unicodeのランダムな文字を出力するコード例

ランダムなUnicodeの文字を一つ表示するプログラム import unicodedata import random def uni(): while True: n = random.randint(0,0x10FFFF) if not unicodedata.category(chr(n)) in ["Cn", "Co"]: break return chr(n) print(uni()) 解説 unicodedata.c…