在循环中动态生成变量

while (month_lag >= '201601'):
   locals()["lc_"+month_lag] = get_month_lc(-i)
   month_lag = utility.datetime_month_lag(-i)[3]
   i=i+1

   print('The iter_lc is:', month_lag)


通过locals()["lc_"+month_lag],在循环中就动态生成变量 

猜你喜欢

转载自blog.csdn.net/butterfly1107/article/details/80091341