Python dir() 函数
发布日期:2021-06-30 10:37:26 浏览次数:2 分类:技术文章

本文共 778 字,大约阅读时间需要 2 分钟。

dir() 函数

不带参数时

返回的内容:变量名、方法名和定义类名

print(dir())

['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']

 

带参数时,

返回的内容:参数的属性(变量名)、方法名

print(dir([]))

['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

 

 

转载地址:https://it-chengzi.blog.csdn.net/article/details/107812916 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:详解Python中函数和模块的特殊属性__annotations__
下一篇:视频编码的理解

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月07日 13时34分56秒