【错误记录】PyCharm 运行 Python 程序报错 ( SyntaxError: Non-ASCII character ‘xe5‘ in file x.py on line 1, but )

2023-03-29 18:30:30 浏览数 (3)

文章目录

  • 一、报错信息
  • 二、解决方案

一、报错信息


代码语言:javascript复制
Y:02_WorkSpacePycharmProjectsAPKvenvScriptspython.exe Y:/002_WorkSpace/PycharmProjects/APK/main.py
  File "Y:/002_WorkSpace/PycharmProjects/APK/main.py", line 1
SyntaxError: Non-ASCII character 'xe5' in file Y:/002_WorkSpace/PycharmProjects/APK/main.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Process finished with exit code 1

二、解决方案


在代码第一行添加 如下内容 :

代码语言:javascript复制
# coding=utf-8

添加了 # coding=utf-8 后 , Python 程序可运行 ;

0 人点赞