小编给大家分享一下查看python文档的方法,相信大部分人都还不怎么了解,因此分享这边文章给大家学习,希望大家阅读完这篇文章后大所收获,下面让我们一起去学习方法吧!

查看文档是一个程序员的基本功,这里简单介绍几种查看Python文档的方法,下面以struct模块为例。

1.help

在交互模式下,help函数是获取文档的好帮手,使用非常简单。

>>>importstruct>>>help(struct)Helponmodulestruct:NAMEstructDESCRIPTIONFunctionstoconvertbetweenPythonvaluesandCstructs.PythonbytesobjectsareusedtoholdthedatarepresentingtheCstructandalsoasformatstrings(explainedbelow)todescribethelayoutofdataintheCstruct.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.在线文档。

以上是查看python文档的方法的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!