python getattr函数实用技巧

版权声明:未经本人同意,禁止转载! https://blog.csdn.net/TianPingXian/article/details/83000839

getattr比较实用

class test:
	name='morgan'
	def test(self):
		print('test')

t = test()
getattr(t,'name')  #获取 name 属性
getattr(t,'test')

猜你喜欢

转载自blog.csdn.net/TianPingXian/article/details/83000839