pycharm的console显示乱码和中文的配置

Posted 爱吃虫的人

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pycharm的console显示乱码和中文的配置相关的知识,希望对你有一定的参考价值。

console中文显示乱码问题:

在settings->File encoding界面选择
IDE Encodingproject Encoding(推荐都设置成utf-8)
不过这个设置貌似和程序的编码有关,鉴于一般都是万国码。所以还是这样方便点。

 

console中显示unicode编码,设置成显示成中文:

Configuring Output Encoding

PyCharm creates files using the IDE encoding defined in the File Encodings page of the Settings dialog, which can be either system default, or the one selected from list of available encodings. Output in the consoles is also treated in this encoding.

It is possible that encoding used in the console output is different from the IDE default. To have PyCharm properly parse text in the console, you have to do some additional editing.

To set up encoding for the console output, depending on your operating system:

    • In Windows and Linux:

      Open for editing PYCHARM_HOME/bin/pycharm.exe.vmoptions 
      or
      PYCHARM_HOME/bin/pycharm.vmoptions

      respectively, and add the following line at the bottom:
      -Dconsole.encoding=<encoding name>

      For example:
      -Dconsole.encoding=UTF-8
       
       
    • In macOS: Open Info.plist located in /应用程序/PyCharm/Contents/, locate the tag <key>VMOptions</key>, and modify it as follows:

      <key>VMOptions</key> <string>-Xms16m -Xmx512m -XX:MaxPermSize=120m -Xbootclasspath/p:../lib/boot.jar -ea -Dconsole.encoding=<encoding name> </string>
      没有-Dconsole.encoding=<encoding name>,需要在文本中添加这部分内容,并将encoding name更改成UTF-8
      保存以后,重启pycharm生效
       
       

以上是关于pycharm的console显示乱码和中文的配置的主要内容,如果未能解决你的问题,请参考以下文章

解决问题,在pycharm中使用graphviz绘制决策树时,决策树图片中不显示中文(中文字体乱码!!) 图文并茂版!!!

PyCharm控制台输出乱码

PyCharm----中文显示乱码的解决方法总结

pycharm数据库字段改中文名称后乱码?

usb转db9 再用console线连接交换机console口怎么显示乱码?

PyCharm控制台输出乱码