1. 程式人生 > >pycharm的console顯示亂碼和中文的配置

pycharm的console顯示亂碼和中文的配置

size 亂碼 DC rap 推薦 create diff files 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顯示亂碼和中文的配置