【发布时间】:2014-05-03 14:09:56
【问题描述】:
我有:
Variable1 = "list1"
和
list1 = ["a", "b", "c", "d"]
如何通过变量 Variable1 访问/操作 list1 项(并将所有标准列表运算符/函数应用于 list1)
有点像
token = random.choice($UnknownOperator$(Variable1))
and token would be equal either to a b c or d
谢谢!
【问题讨论】:
-
如果您将
list1存储在字典 中,则不会出现此问题。 Keep your data out of your variable names. -
@MartijnPieters 我终于不再拼错你的名字了!我觉得我花太多时间在 SO........