python vars 的用法
#!/usr/bin/env python# -*- encoding: utf-8 -*-"""@Introduce : vars 的 用法@File: test1.py@Time: 2020/9/11 11:27@Author: 夏华东@Tel: 150 021 96021@Emile: 15002196021@163.com@pip: pip install"""class A(object
·
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Introduce : vars 的 用法
@File : test1.py
@Time : 2020/9/11 11:27
@Author : 夏华东
@Tel : 17317976823
@Emile : 17317976823@163.com
@pip : pip install
"""
class A(object):
d = 3
def __init__(self):
self.b = 1
self.c = 2
def vars_example(obj):
"""
vars 的 用法
:param obj: 类
:return: 类属性组成的字典
"""
dic = vars(obj)
print(dic)
return dic
if __name__ == '__main__':
a = A()
vars_example(a)
更多推荐
已为社区贡献16条内容
所有评论(0)