爲簡單起見,這是什麼,我想要做一個精簡版:如何獲得一個變量的值在一個字符串中的名稱?
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"
沒有辦法做到這一點?
'當地人()'當地人。 – 2012-02-24 20:49:19