Python dir和vars的区别
生活随笔
收集整理的這篇文章主要介紹了
Python dir和vars的区别
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
dir()和vars()的區(qū)別就是
dir()只打印屬性(屬性,屬性......)
而vars()則打印屬性與屬性的值(屬性:屬性值......)
ex.
>> a='aaaaaaaaaaaaa' >> class b: >> c = 'cccc'>> dir() >>['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'a', 'b'] >> vars() >> {'a': 'aaaaaaaaaaaaa', 'b': , '__builtins__': , '__file__': 'C:\\Users\\CS11\\Desktop\\test.py', '__package__': None, '__name__': '__main__', '__doc__': None} >> dir(b) >>['__doc__', '__module__', 'c']>> vars(b) >>{'__module__': '__main__', 'c': 'cccc', '__doc__': None}轉(zhuǎn)載于:https://www.cnblogs.com/leisurelylicht/p/Python-dir-hevars-de-qu-bie.html
總結(jié)
以上是生活随笔為你收集整理的Python dir和vars的区别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 从零打造在线网盘系统之Hibernate
- 下一篇: #pragma multi_compil