PyCharm运行报编码错误

运行报如下错误:

 

SyntaxError: Non-ASCII character '\xe8' in file /home/ubuntu/code/201803091253-text.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

解决方案:

在Python文件第一行,最前面加如下代码:

# -*- coding: utf-8 -*-

# 声明字符编码
# coding:utf-8
print('输出中文')



 

posted @ 2018-03-09 14:36  begrateful  阅读(1060)  评论(0编辑  收藏  举报