如何从今天的日期中提取该月和上个月的文本值?我在下面获取整数值。
today = datetime.date.today()
first = today.replace(day=1)
current_month = first - datetime.timedelta(days=1)
current_month = current_month.strftime("%m")
current_month = int(current_month)
last_month = current_month - 1
我有一个包含数字和月份值的文件,因此我正在考虑使用该文件映射到整数。看起来像是一个数据框:
Number Month
1 January
2 February
3 March
4 April
5 May
6 June
7 July
8 August
9 September
10 October
11 November
12 December