加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

【Python】Python中的多行注释文档编写风格汇总

发布时间:2020-12-17 01:23:05 所属栏目:Python 来源:网络整理
导读:p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,arial,宋体;" 【笔记】 p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size:

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,arial,宋体;">【笔记】

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,宋体;">Epytext风格比较紧凑(推荐);

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,宋体;">Google风格和numpy风格层次分明,但是比较长;

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,宋体;">================================

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,宋体;">什么是docstring

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,宋体;">在软件工程中,其实编码所占的部分是非常小的,大多是其它的事情,比如写文档。文档是沟通的工具。
在Python中,比较推崇在代码中写文档,代码即文档,比较方便,容易维护,直观,一致。
代码写完,文档也出来了。其实Markdown也差不多这种思想,文本写完,排版也完成了。
看看PEP 0257中对docstring的定义:

<p style="margin-top: 0px; margin-bottom: 0px; padding-top: 5px; padding-bottom: 5px; font-size: 14px; font-family: tahoma,宋体;">A docstring is a string literal that occurs as the first statement in
a module,function,class,or method definition. Such a docstring
becomes the doc special attribute of that object.
简单来说,就是出现在模块、函数、类、方法里第一个语句的,就是docstring。会自动变成属性doc

<div class="jb51code" style="margin: 0px; padding: 0px; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; font-family: tahoma,宋体;"><div style="margin: 0px; padding: 0px; line-height: 25.2px;"><div id="highlighter_455421" class="syntaxhighlighter py" style="padding: 0px; width: 643px; line-height: 25.2px; margin: 1em 0px !important; position: relative !important; overflow: auto !important;"><div class="toolbar" style="line-height: 13.2px; margin: 0px !important; padding: 0px !important; border-radius: 0px !important; background: rgb(108,226,108) !important; border: none !important; bottom: auto !important; float: none !important; height: 11px !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: absolute !important; right: 1px !important; top: 1px !important; vertical-align: baseline !important; width: 11px !important; box-sizing: content-box !important; font-family: Consolas,"Bitstream Vera Sans Mono","Courier New",Courier,monospace !important; min-height: auto !important; z-index: 10 !important; color: white !important;"><span style="line-height: 21.6px; font-size: 12px;"><a target=_blank href="http://www.52php.cn/article/86757.htm#" rel="nofollow" class="toolbar_item command_help help" style="color: rgb(0,102,153); text-decoration-line: none; font-size: 14px; border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 1px 0px 0px !important; position: static !important; right: auto !important; text-align: center !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: auto !important; display: block !important;">?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读