Python内置函数—vars的具体使用方法
本文文章主要介绍了Python内置函数―vars的具体使用方法,分享给大家,具体如下:varsReturn the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.Objects such as modules and instances have an updateable __dict__ attribute; however, other objects may have write restrictions on their __dict__ attributes .Without an argument, vars() acts like locals(). Note, the locals dictionary is only useful for reads since updates to the locals dictionary are ignored.object -- 对象返回对象object的属性和属性值的字典对象,如果没有参数,就打印当前调用位置的属性和属性值 类似 locals()。说明1. 当函数不接收参数时,其功能和locals函数一样,返回当前作用域内的局部变量。本函数是实现返回对象object的属性和属性值的字典对象。如果默认不输入参数,就打印当前调用位置的属性和属性值,相当于locals()的功能。
下载地址
用户评论