一、日期月份转为英文(简写)
import calendar date_list = [1,2,3,4,5,6,7,8,9,10,11,12] #数字转为月份简写 for i in date_list: print(calendar.month_abbr[i])
输出:
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
二、日期月份转为英文(全称)
date_list = [1,2,3,4,5,6,7,8,9,10,11,12] #数字转月份的全写 for i in date_list: print(calendar.month_name[i])
输出:
January February March April May June July August September October November December
三、日期月份英文转为数字月份
# 简写月份转数字 month_abbr_list = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] for i in month_abbr_list: print( list(calendar.month_abbr).index(i) )
输出:
1 2 3 4 5 6 7 8 9 10 11 12
参考: