博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 获取类方法_使用Python获取类方法
阅读量:2517 次
发布时间:2019-05-11

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

python 获取类方法

As a newbie to the excellent world of Python development, I'm not always familiar with the methods provided by imported classes.  Oftentimes these classes are well-documented but in the case that methods aren't documented, I found the dir function useful for getting a list of methods:

作为Python开发卓越世界的新手,我并不总是熟悉导入类提供的方法。 通常,这些类的文档有据可查,但是在没有文档记录方法的情况下,我发现dir函数对于获取方法列表很有用:

# dir({object})dir(difflib)"""Returns:['Differ', 'HtmlDiff', 'IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'Match', 'SequenceMatcher', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_calculate_ratio', '_count_leading', '_file_template', '_legend', '_mdiff', '_namedtuple', '_styles', '_table_template', '_test', 'context_diff', 'get_close_matches', 'heapq', 'ndiff', 'reduce', 'restore', 'unified_diff']"""

The snippet above does exactly what you would expect -- provides a list of method names for the viewing!

上面的代码片段完全符合您的期望-提供用于查看的方法名称列表!

翻译自:

python 获取类方法

转载地址:http://duvwd.baihongyu.com/

你可能感兴趣的文章
解密zend-PHP凤凰源码程序
查看>>
python3 序列分片记录
查看>>
Atitit.git的存储结构and 追踪
查看>>
atitit 读书与获取知识资料的attilax的总结.docx
查看>>
B站 React教程笔记day2(3)React-Redux
查看>>
找了一个api管理工具
查看>>
Part 2 - Fundamentals(4-10)
查看>>
使用Postmark测试后端存储性能
查看>>
NSTextView 文字链接的定制化
查看>>
第五天站立会议内容
查看>>
(转))iOS App上架AppStore 会遇到的坑
查看>>
做好产品
查看>>
项目管理经验
查看>>
JMeter响应数据出现乱码的处理-三种解决方式
查看>>
No qualifying bean of type available问题修复
查看>>
spfile
查看>>
Team Foundation Service更新:改善了导航和项目状态速查功能
查看>>
Cookie/Session机制具体解释
查看>>
ATMEGA16 IOport相关汇总
查看>>
JAVA基础-多线程
查看>>