这可能很简单,但我有一个字符串列表,也对应于变量名:
listname = ['name1', 'name2," ... ]
name1 = "somestring"
name2 = "some other string"
我想做的是:
for variable in listname:
[perform some operation on the string associated with the variables
named in listname, i.e. "somestring" and then "some other string," etc.]
有没有一种简单的方法可以强制将字符串listname
作为变量进行评估?