1.文档资源列表
形式 |
角色 |
#注释 |
文件中的文档 |
dir函数 |
对象中可用属性列表 |
文档字符串:__doc__ |
附近在对象上的文档 |
pydoc:help() |
对象的交互帮助 |
pydoc:html报表 |
浏览器中的模块文档 |
标准手册 |
正式的语音和库的说明 |
网站资源 |
在线教程、例子等 |
出版的书籍 |
商业参考书籍 |
2.注释
使用#号注释,一般用来说明小功能,如果较大型的功能,一般使用文档字符串
>>> aList=[]#新建一个列表
3.dir()
内建函数dir()抓取对象内可用所有属性列表的简单方式
>>> import sys
>>> dir(sys)
['__displayhook__', '__doc__', '__excepthook__', '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_debugmallocstats', '_getframe', '_home', '_mercurial', '_xoptions', 'api_version', 'argv', 'base_exec_prefix', 'base_prefix', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode', 'exc_info', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'getallocatedblocks', 'getcheckinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval', 'gettrace', 'getwindowsversion', 'hash_info', 'hexversion', 'implementation', 'int_info', 'intern', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr', 'stdin', 'stdout', 'thread_info', 'version', 'version_info', 'warnoptions', 'winver']
>>>
如果需要找出对象提供的属性与方法,我们可以传入一个空的对象,如:
>>> dir(())
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']
>>> dir([])
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__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']
>>> dir('')
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>>
或者我们也可以传递这个对象的名字:
>>> dir(str)==dir('')
True
>>> dir(list)==dir([])
True
>>>
总结,这一章节主要列举了文档资源,并且简单说明了一下注释和dir函数
这一章节就说到这里,谢谢大家
------------------------------------------------------------------
点击跳转零基础学python-目录
版权声明:本文为博主原创文章,未经博主允许不得转载。
分享到:
相关推荐
python 零基础学习篇-Python-第八章:文件的使用1.mp3
python 零基础学习篇-Python-第七章:函数的设计和使用1-3.mp3
python 零基础学习篇-Python-第七章:函数的设计和使用4-9.mp3
### 零基础学Python-1.pdf 知识点概览 #### Python 介绍与安装 - **为何学习编程:** 编程不仅限于成为软件开发者,它更是一种思维方式的训练,帮助人们更好地理解问题并寻找解决方案。 - **乔布斯关于编程的看法:...
pkg-catkin-pkg无法下载,我7月底重装了一次Ubuntu14.04,安装ros lidigo时报错,依赖python-catkin-pkg,但它不会被安装,我刚开始发现这个问题时试过换源,重装系统均不成功,后面去官方论坛和资源网才发现这个...
python-can库的使用脚本: 通过python-can,无需canoe license就可以实现can报文的收发,支持多个硬件,包括PCAN\USBCAN\Kvaser\Vector CANoe盒子等 从中可以学习python-can库API接口如BUS、Message、Hardware ...
python-gtk 2013年7月31日 python入门基础教程:python-gtk全文共15页,当前为第1页。 安装 sudo aptitude install python-gtk2 文档 ...
python 零基础学习篇-2、第二章:系统架构设计的案例分析1-27.mp3
python3.8.11的官方基础镜像,什么都没装的,很小114M.
资源分类:Python库 所属语言:Python 资源全名:executor-14.1-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Python-docx是一个强大的Python库,专门用于处理Microsoft Word文档,如创建、编辑和读取.docx格式的文件。这个库允许开发者在不依赖Microsoft Office的情况下,通过编程方式操作Word文档,极大地扩展了Python在文档...
libselinux-python-2.5-14.1.el7.x86_64.rpm python-IPy-0.75-6.el7.noarch.rpm docker-ce-cli-19.03.8-3.el7.x86_64.rpm checkpolicy-2.5-8.el7.x86_64.rpm policycoreutils-python-2.5-33.el7.x86_64.rpm ...
python-pptx库英文文档完整版,本站第一个发布。 不管你爱不爱,Powerpoint都被广泛应用于商务场合。文章不会争辩Powerpoint的优点,而是向你展示如何用Python使创建Powerpoint幻灯片自动化,以便去除掉在使用...
python 零基础学习篇-Python-第六章 字符串1-3.mp3
"let's-python-源码" 是一个与"let's-python"系列视频相关的代码资源集合,提供了该教程中的各种示例和练习的源代码。这个压缩包涵盖了从基础到进阶的多个Python编程主题,旨在帮助学习者提升Python编程技能。 在...
python 零基础学习篇-Python-第二章 顺序程序设计9-12.mp3
python 零基础学习篇-Python-第二章 顺序程序设计1-8.mp3
015字符串:格式化.mp4 77.4M2019-07-26 16:23 014字符串:各种奇葩的内置方法.mp4 97M2019-07-26 16:23 013元组:戴上了枷锁的列表.mp4 33.8M2019-07-26 16:23 ...001我和Python的第一次亲密接触.mp4
python 零基础学习篇-Python-第九章 面向对象程序设计1-6.mp3