初学python常遇错误--python脚本程序报错

程序: 

#!/usr/bin/python
#根据给定的年月日以数字的形式打印出日期
months=['January','February','March','April','May','June','July','August','September','October','November','December']

#以1-31的数字作为结尾的列表
endings=['st','nd','rd']+17*['th'] \
       +['st','nd','rd']+7*['th'] \
       +['st']
year=raw_input('Year:')
month=raw_input('Month:')
day=raw_input('Day(1-31):')

month_number=int(month)
day_number=int(day)

month_name=months[month_number-1]
ordinal=day_number+endings[day_number-1]
print month_name+' '+ordinal+', '+year

报错:File "./sequence_1.py", line 2
SyntaxError: Non-ASCII character '\xe6' in file ./sequence_1.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

解决方法:
在#!/usr/bin/python后面,脚本前面加上#-*-coding=utf-8-*-

你可能感兴趣的:(python,脚本,File,input,character,encoding)