SyntaxError: Non-ASCII character '\xe4' in file test1.py on line 8, but no encoding declared;

MongoDB  SyntaxError: Non-ASCII character '\xe4' in file test1.py on line 8, but no encoding declared;

 

 python脚本内容

MongoDB  SyntaxError: Non-ASCII character '\xe4' in file test1.py on line 8, but no encoding declared;

 

1、原因

Python默认是以ASCII作为编码方式的,需要在文件开头设置一下编码

2、解决方案 

# -*- coding: UTF-8 -*-    
或者
#coding=utf-8

3、处理后效果

MongoDB  SyntaxError: Non-ASCII character '\xe4' in file test1.py on line 8, but no encoding declared;

相关文章:

  • 2021-09-25
  • 2022-01-03
  • 2021-06-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-12-11
  • 2021-04-17
  • 2022-12-23
相关资源
相似解决方案