python除了提供__doc__来查询文档字符串,还提供另外的一种方法来查询文档字符串:help
下面是我们自己建立的一个类,使用help打印,形成相关的报表信息
>>> class Test():
'这是一个测试类'
def helloworld():
'测试方法'
print('hello world')
>>> help(Test)
Help on class Test in module __main__:
class Test(builtins.object)
| 这是一个测试类
|
| Methods defined here:
|
| helloworld()
| 测试方法
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
>>>
注意:在使用help的时候必须填写名称,不能使用空对象替代,例如:
>>> help('')
>>> help(str)
Help on class str in module builtins:
class str(object)
| str(object='') -> str
| str(bytes_or_buffer[, encoding[, errors]]) -> str
|
但是,如果调用的是对象下面的方法,我们到可以通过空对象来实现
>>> help(''.upper )
Help on built-in function upper:
upper(...) method of builtins.str instance
S.upper() -> str
Return a copy of S converted to uppercase.
>>> help([].append )
Help on built-in function append:
append(...) method of builtins.list instance
L.append(object) -> None -- append object to end
>>>
还有一点需要注意的是,方法后面不带括号,带上括号将会查询不到,即便这个方法必须带上参数,也不用用上括号
>>> help(''.upper() )
>>>
>>> help(''.replace )
Help on built-in function replace:
replace(...) method of builtins.str instance
S.replace(old, new[, count]) -> str
Return a copy of S with all occurrences of substring
old replaced by new. If the optional argument count is
given, only the first count occurrences are replaced.
>>>
总结,这一章节我们简单说明了help的使用
这一章节就说到这里,谢谢大家
------------------------------------------------------------------
点击跳转零基础学python-目录
版权声明:本文为博主原创文章,未经博主允许不得转载。
分享到:
相关推荐
python 零基础学习篇-Python-第七章:函数的设计和使用1-3.mp3
python 零基础学习篇-Python-第七章:函数的设计和使用4-9.mp3
python 零基础学习篇-Python-第八章:文件的使用1.mp3
python 零基础学习篇-Python-第八章:文件的使用2-12.mp3
设计名称 Python函数 授课课时 1.0 学情分析 学生知识经验基础 已经掌握Python程序编码软件基本的操作技能和基础语法。 已学习Python语句的三种逻辑结构:顺序、条件分支、循环,可以进一步提高编程技能,学习函数...
Python基础与办公自动化应用--教案-项目五:函数与模块全文共6页,当前为第1页。Python基础与办公自动化应用--教案-项目五:函数与模块全文共6页,当前为第1页。 Python基础与办公自动化应用--教案-项目五:函数与...
python-gtk 2013年7月31日 python入门基础教程:python-gtk全文共15页,当前为第1页。 安装 sudo aptitude install python-gtk2 文档 ...
python 零基础学习篇-2、第二章:系统架构设计的案例分析1-27.mp3
零基础学python 1.7 第二个程序
零基础入门学习Python-价值200的鱼C论坛教程
python 零基础学习篇-Python-第一章 Python入门导入1-3.mp3
python-pptx库英文文档完整版,本站第一个发布。 不管你爱不爱,Powerpoint都被广泛应用于商务场合。文章不会争辩Powerpoint的优点,而是向你展示如何用Python使创建Powerpoint幻灯片自动化,以便去除掉在使用...
python免费课件-零基础python⼊门(含课件代码)PDF⾼清 版 给⼤家带来的⼀篇关于python相关的电⼦⽂档资源,介绍了关于python⼊门、python基础⽅⾯的内容,本书是由python官⽅出版,格式 为PDF,资源⼤⼩61 MB,⽥...
python 零基础学习篇-Python-第六章 字符串1-3.mp3
python 零基础学习篇-Python-第三章 使用序列1-12.mp3
python 零基础学习篇-Python-第二章 顺序程序设计9-12.mp3
python 零基础学习篇-Python-第二章 顺序程序设计1-8.mp3
python 零基础学习篇-Python-第九章 面向对象程序设计1-6.mp3
python 零基础学习篇-Python-第四章 选择结构程序设计1-6.mp3
多线程精品资源--Python实用教程,包括:Python基础,Python高级特性,面向对象编程,多线程,数据库,