Created
February 13, 2013 11:21
-
-
Save mihyaeru21/4943945 to your computer and use it in GitHub Desktop.
文字数を数えたいときは unicode型 に対して len() を使え、俺。
エンコードが指定されている時はバイト数が返されるべ。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UTF-8 な環境です | |
>>> len("コレハハンカクカナデス") | |
36 | |
>>> len(u"コレハハンカクカナデス") | |
12 | |
>>> len("これは全角") | |
15 | |
>>> len(u"これは全角") | |
5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment