擅长:python、mysql、java
<p>我假设你的目标是间接获得价值观。在这种情况下,考虑将变量放入类或字典中。下面是课堂教学法的一个例子:</p>
<pre><code>class mydata(object):
arg = "school"
arg_2 = "college"
school = "enjoy"
college = "study"
def value_of_value(self, s):
return getattr(self, getattr(self, s))
x = mydata()
print 'arg->', x.value_of_value('arg')
print 'arg_2->', x.value_of_value('arg_2')
</code></pre>
<p>这将产生:</p>
<pre><code>arg-> enjoy
arg_2-> study
</code></pre>