python 动态定义变量名并动态赋值

t = [‘B0716PK6R2’,‘B077X9J24C’,‘B01N2SBH4J’]
count = 0
names = locals()
for asin in t:
count = count + 1
names[‘asin’ + str(count)] = asin

print(asin1,asin2,asin3)

# 输出结果:

B0716PK6R2 B077X9J24C B01N2SBH4J

上一篇:【Beta】Scrum meeting 4


下一篇:获取目录下文件名