打开Pycharm,按以下顺序点击, File》Settings》Editor》Code Style》File and Code Templates》Python Script 在框中加上 # *coding:utf-8 * 即可,如下图所示: