擅长:python、mysql、java
<pre><code>class A(object):
def __init__(self):
self.data = {'a': 'v1', 'b': 'v2'}
def __getattr__(self, attr):
try:
return self.data[attr]
except:
return "not found"
>>>a = A()
>>>print a.a
v1
>>>print a.c
not found
</code></pre>