![图片[1]-怎么查看python文档-uusu优素-乐高,模型,3d打印,编程](http://uusucn.zbbe.cn/wp-content/uploads/2024/01/5e70d58d0349a124.jpg)
查看文档是一个程序员的基本功,这里简单介绍几种查看Python文档的方法,下面以struct模块为例。
1.help
在交互模式下,help函数是获取文档的好帮手,使用非常简单。
>>>importstruct >>>help(struct) Helponmodulestruct: NAME struct DESCRIPTION FunctionstoconvertbetweenPythonvaluesandCstructs. PythonbytesobjectsareusedtoholdthedatarepresentingtheCstruct andalsoasformatstrings(explainedbelow)todescribethelayoutofdata intheCstruct. Theoptionalfirstformatcharindicatesbyteorder,sizeandalignment: @:nativeorder,size&alignment(default) =:nativeorder,std.size&alignment <:little-endian,std.size&alignment >:big-endian,std.size&alignment !:sameas> Theremainingcharsindicatetypesofargsandmustmatchexactly; thesecanbeprecededbyadecimalrepeatcount: x:padbyte(nodata);c:char;b:signedbyte;B:unsignedbyte; ?:_Bool(requiresC99;ifnotavailable,charisusedinstead) h:short;H:unsignedshort;i:int;I:unsignedint;
2.__doc__
__doc__是每个对象都有的属性,其存放了对象文档。
3.离线文档
安装Python时会自带一个chm格式的离线文档Python documention,该文档的信息比较全。
4.离线模块文档
Python针对模块还有一个单独的文档,该文档在浏览器中查看。
5.在线文档。
原文来自:https://www.py.cn© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
















































暂无评论内容