Syntaxerror:non-ascii character ' \xe6 ' in file./1.py on line 3, but no encoding declared; See http://www.python.org/peps/pep-0263.html for details
Baidu checked it out because Python does not support encoding in the source file by default.
Add the following two lines of comment code to the file header:
#!/usr/bin/env python
# Vim:set fileencoding=<encoding name>: For example, you can add # Vim:set Fileencoding=utf-8:
The following is the revised complete code:
#!/usr/bin/env python
# Vim:set Fileencoding=utf-8:
#根据给定的年月日以数字形式打印出日期
months = [
' January ',
' February ',
' March ',
' April ',
' May ',
' June ',
' July ',
' August ',
' September ',
' October ',
' November ',
' December '
]
#以1 ~31 Number as the end of the list
endings = [' st ', ' nd ', ' Rd '] + + * [' th ']\
+ [' st ', ' nd ', ' Rd '] + 7 * [' th ']\
+ [' st ']
Year = Raw_input (' Year: ')
month = Raw_input (' Month (1-12): ')
Day = Raw_input (' Day (1-31): ')
month_number = Int (month)
day_number = Int (day)
#记得要将月份和天数减1 to get the correct index
Month_name = Months[month_number-1]
Ordinal = day + endings[day_number-1]
Print Month_name + ' + ordinal + ', ' + year
Python appears syntaxerror:non-ascii character ' \xe6 ' in file error