We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第一个参数为类对象,第二个参数为属性的list to_dict (object,attr_list): obj = {} for key in attr_list: obj[key] = getattr(object, key, None) return obj
比如要获取 cat 的eat ,color,size ,age ,long,weight等属性 attr_list = [eat ,color,size ,age ,long,weight] 调用方法为 to_dict(cat,attr_list)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
第一个参数为类对象,第二个参数为属性的list
to_dict (object,attr_list):
obj = {}
for key in attr_list:
obj[key] = getattr(object, key, None)
return obj
比如要获取 cat 的eat ,color,size ,age ,long,weight等属性
attr_list = [eat ,color,size ,age ,long,weight]
调用方法为 to_dict(cat,attr_list)
The text was updated successfully, but these errors were encountered: