The following code:
class A:
def __init__(self, a,b):
self.a=a
self.b=b
temp_text=A(1,2)
If i want to get temp_text.a
.
How could i get this from a string "a"?
such as :temp_text."a"
You need the function getattr
for this:
getattr(temp_text, 'a')