SyntaxError: Non-ASCII character '\xe5' in file test23.py on line 2, but no encoding declared;

 
pip -V
python3 -m pip install --upgrade --force pip
pip -V
 
WARNING: The scripts pip, pip3 and pip3.8 are installed in '/usr/local/python3/bin' which is not on PATH.
 
 
 
 
 
[echo0282@instance-1 ~]$ python test23.py
File "test23.py", line 2
SyntaxError: Non-ASCII character '\xe5' in file test23.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
[echo0282@instance-1 ~]$
 
解决方法:
在文件头加上这行:
# -*- coding: utf-8 -*-
 
 
 
查看crontab任务运行日志:
tail -f /var/log/cron
 
此外,为crontab中的任务增加日志,这样出错后,容易看到原因。
 
0 6 * * * $HOME/for_crontab/createTomorrowTables >> $HOME/for_crontab/mylog.log 2>&1
 
 
 


posted @ 2021-02-25 21:59  Orchidelle  阅读(219)  评论(0编辑  收藏  举报