【发布时间】:2012-03-15 07:33:30
【问题描述】:
为简单起见,这是我想做的精简版:
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"
有什么办法吗?
【问题讨论】: