Last Update 2025/08/31
概要
識別子使用可能文字のテスト
sample.py
UnicodeカテゴリコードはPython 言語リファレンスから引用
各文字に関する詳細情報はhttps://www.unicode.org/Public/15.0.0/ucd/DerivedCoreProperties.txtを参照
UnicodeカテゴリコードはPython 言語リファレンスから引用
各文字に関する詳細情報はhttps://www.unicode.org/Public/15.0.0/ucd/DerivedCoreProperties.txtを参照
a = "Ll(LATIN SMALL LETTER A)" # 0061
ѥ = "Ll(CYRILLIC SMALL LETTER IOTIFIED E)" # 0465
abcdefghijklmnopqrstuvwxyz = "Ll(LATIN SMALL LETTER A..LATIN SMALL LETTER Z)" # 0061 .. 007A
ABCDEFGHIJKLMNOPQRSTUVWXYZ = "Lu(LATIN CAPITAL LETTER A..LATIN CAPITAL LETTER Z)" # 0041 .. 005A
Dz = "Lt(LATIN CAPITAL LETTER D WITH SMALL LETTER Z)" # 01F2
ˮ = "Lm(MODIFIER LETTER DOUBLE APOSTROPHE)" # 02EE
あ = "Lo(HIRAGANA LETTER)" # 3042
Ⅷ= "Nl(ROMAN NUMERAL)" # 2167
a0 = "Ll + Nd(DIGIT ZERO)" # 0061 + 0030
a_ = "Ll + Pc(LOW LINE)" # 0061 + 005F
print("Unicode カテゴリコード")
print("Lu - 大文字 (uppercase letters)")
print("Ll - 小文字 (lowercase letters)")
print("Lt - 先頭が大文字 (titlecase letters)")
print("Lm - 修飾文字 (modifier letters)")
print("Lo - その他の文字 (other letters)")
print("Nl - 数値を表す文字 (letter numbers)")
print("Nd - 10 進数字 (decimal numbers)")
print("Pc - 連結用句読記号 (connector punctuations)\n")
print("a :", a)
print("ѥ :", ѥ)
print("ABCDEFGHIJKLMNOPQRSTUVWXYZ :", ABCDEFGHIJKLMNOPQRSTUVWXYZ)
print("abcdefghijklmnopqrstuvwxyz :", abcdefghijklmnopqrstuvwxyz)
print("Dz :", Dz)
print("ˮ :", ˮ)
print("あ :", あ)
print("Ⅷ :", Ⅷ)
print("a0 :", a0)
print("a_ :", a_)
実行結果
Unicode カテゴリコード
Lu - 大文字 (uppercase letters)
Ll - 小文字 (lowercase letters)
Lt - 先頭が大文字 (titlecase letters)
Lm - 修飾文字 (modifier letters)
Lo - その他の文字 (other letters)
Nl - 数値を表す文字 (letter numbers)
Nd - 10 進数字 (decimal numbers)
Pc - 連結用句読記号 (connector punctuations)
a : Ll(LATIN SMALL LETTER A)
ѥ : Ll(CYRILLIC SMALL LETTER IOTIFIED E)
ABCDEFGHIJKLMNOPQRSTUVWXYZ : Lu(LATIN CAPITAL LETTER A..LATIN CAPITAL LETTER Z)
abcdefghijklmnopqrstuvwxyz : Ll(LATIN SMALL LETTER A..LATIN SMALL LETTER Z)
Dz : Lt(LATIN CAPITAL LETTER D WITH SMALL LETTER Z)
ˮ : Lm(MODIFIER LETTER DOUBLE APOSTROPHE)
あ : Lo(HIRAGANA LETTER)
Ⅷ : Nl(ROMAN NUMERAL)
a0 : Ll + Nd(DIGIT ZERO)
a_ : Ll + Pc(LOW LINE)
キーワードとソフトキーワードの一覧を出力
sample.py
import keyword
print("---------- キーワード ----------")
for s in keyword.kwlist:
print(s)
print("---------- ソフトキーワード ----------")
for s in keyword.softkwlist:
print(s)
実行結果
---------- キーワード ----------
False
None
True
and
as
assert
async
await
break
class
continue
def
del
elif
else
except
finally
for
from
global
if
import
in
is
lambda
nonlocal
not
or
pass
raise
return
try
while
with
yield
---------- ソフトキーワード ----------
_
case
match
type
実行環境
Python 3.12.11
コード例・出力内容中の表記
・実行例中の太字表記部分は、コマンドなどの入力された文字列を示します。
・「︙」や「...」の着色省略表記は、 実際のソースコードや出力内容などを省略加工した部分を示します。
・「︙」や「...」の着色省略表記は、 実際のソースコードや出力内容などを省略加工した部分を示します。