To print Japanese kana in Python, the easiest way is to use Unicode strings. Unicode is a universal system that assigns a unique number to every character in every writing system, including Japanese. Python 3.x natively supports Unicode strings and literals, so a string of Unicode kana characters can be printed as-is:
main.py117 chars5 lines
Note the # -*- coding: utf-8 -*-
line at the top. This tells Python to interpret the Python source code as UTF-8, which is the most common encoding for Japanese text.
If you are using Python 2.x, you will need to put a "u" in front of the string to indicate that it is a Unicode string:
main.py104 chars5 lines
If you need to work with non-ASCII characters extensively, it is recommended to use a Unicode-aware text editor like Sublime Text or PyCharm.
gistlibby LogSnag