10 lines
209 B
Python
10 lines
209 B
Python
# dir, hasattr e getattr em Python
|
|
string = 'Luiz'
|
|
metodo = 'strip'
|
|
|
|
if hasattr(string, metodo):
|
|
print('Existe upper')
|
|
print(getattr(string, metodo)())
|
|
else:
|
|
print('Não existe o método', metodo)
|