擅长:python、mysql、java
<p>这将取决于您的操作系统和配置,但通常,您只需打印Unicode字符串。如果您的操作系统、默认终端编码和字体支持日语,则只需:</p>
<pre><code>>>> s = u'\u30c9\u30e9\u30b4\u30f3'
>>> print s
ドラゴン
</code></pre>
<p>在Linux上,这要求您的终端正确配置为(通常)UTF-8。在</p>
<p>在Windows上,您需要一个支持UTF-8的IDE,但是如果使用Windows控制台,您将得到一个<code>UnicodeEncodeError</code>,除非使用支持日语的Windows的本地化版本,或者<a href="https://answers.microsoft.com/en-us/surface/forum/surfbook-surfaccess/how-to-change-system-locale-in-windows-10-the/d7826ef0-13cd-43ea-8e01-2846d813dfed?auth=1" rel="nofollow noreferrer">changing the system locale</a>到日语。另一个解决方法是使用<a href="https://pypi.python.org/pypi/win_unicode_console/0.5" rel="nofollow noreferrer">win-unicode-console</a>并安装日语控制台字体。在</p>
<p>上面的例子使用了<a href="https://sourceforge.net/projects/pywin32/" rel="nofollow noreferrer">pywin32</a>模块附带的PythonWin IDE,也可以在标准Python安装附带的pythonwide中工作。在</p>