import datetime
z=datetime.datetime.now()
import dateutil
mon_list=[]
for i in range(10):
monz=z+dateutil.relativedelta.relativedelta(months=-i)
mon_list.append(monz.strftime('%Y%m'))
需要安装dateutil
['202102',
'202101',
'202012',
'202011',
'202010',
'202009',
'202008',
'202007',
'202006',
'202005']