python运行脚本报错Non-UTF-8

写完脚本运行报:SyntaxError: Non-UTF-8 code starting with '\xa1' in file/createuser/test.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

 

解决办法:在脚本最上面也就是第一条写入

# coding=gbk    或者

#encoding = utf-8

然后再次运行

posted @ 2021-06-03 16:15  泡沫夏  阅读(551)  评论(0)    收藏  举报