python利用locals()循环生成变量名

createVar = locals()
for i in city:
createVar[i] = data[data[‘city’]==i]
这里的i是字符串,如果是数值用str(i)变成字符串

你可能感兴趣的:(python编程)