This article mainly introduces the solution to the problem of Pycharm outputting Chinese or printing garbled Chinese characters in python. It has certain reference value. Interested friends can refer to it.
1. Make sure to add the following code at the beginning of the file:
# -*- coding:utf-8 -*-
You can also add
import sys reload(sys) sys.setdefaultencoding('utf-8')
to ensure the following.
If the Chinese garbled characters are still not solved, then proceed to method 2.
2. Enter the setting
## Click to open, click After the modification is completed, the result is as follows Click "ok". success.The above is the detailed content of Solution to the problem of Pycharm outputting Chinese or printing garbled Chinese characters in python (picture). For more information, please follow other related articles on the PHP Chinese website!