如何在字符串中获取给定名称的变量的值?
为简单起见,这是我想要做的精简版:
def foo(a): # I want to print the value of the variable # the name of which is contained in a
我知道如何在PHP中执行此操作:
function foo($a) {
echo $$a;}global $string = "blah"; // might not need to be global but that's irrelevant
foo("string"); // prints "blah"有什么办法吗?
千万里不及你
繁星淼淼
侃侃尔雅
随时随地看视频慕课网APP
相关分类