Python uses locals () loop to generate variable names

createVar = locals ()
for i in city:
createVar [i] = data [data ['city'] == i]
where i is a string, if it is a numeric value, use str (i) to change it

Published 35 original articles · Liked 20 · Visitors 50,000+

Guess you like

Origin blog.csdn.net/weixin_39875181/article/details/103965769