'あ' の Unicode code (なんかややこしいですね) はなーに?といった場合に、
Python ならきっと 'あ'.code() -> '\u3042'
みたいのがあるんじゃないかなーと
漠然と思ってたのですが、探せど探せど見つかりません。(もしあったら教えて下さい)
一応組み込み関数として、ord()
という関数があります。
>>> ord('あ')
12354
なんのこっちゃという感じですが、同じく組み込み関数の hex()
と組み合わせて
16進に変換すると見慣れた形になります。
>>> hex(ord('あ'))
'0x3402'
The Unicode Consortium の 3040 系文字一覧 (PDF) を見る限り正しそうです。
でももっと簡単な方法というかズバリな方法がありそうな気がします。
(もっともあったところで使い道が思いつかないので、やっぱりないのかもしれません)