error detail:
% python today.py
File "today.py", line 2
SyntaxError: Non-ASCII character '\xe4' in file today.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
solutions:
take UTF-8 as an example.
First:
#!/usr/bin/python
#coding:utf-8
from datetime import datetime
print(datetime.now().strftime('今天是%Y年%m月%d日'))
Second:
#!/usr/bin/python
#-*-coding:utf-8 -*-
from datetime import datetime
print(datetime.now().strftime('今天是%Y年%m月%d日'))
Third:
#!/usr/bin/python
#vim: set fileencoding:utf-8
from datetime import datetime
print(datetime.now().strftime('今天是%Y年%m月%d日'))
Note: Python will default to ASCII as standard encodi