如何在Python中记录模块? [英] How do I document a module in Python?

查看:71
本文介绍了如何在Python中记录模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就是这样。如果要记录函数或类,请在定义之后放置一个字符串。例如:

That's it. If you want to document a function or a class, you put a string just after the definition. For instance:

def foo():
    """This function does nothing."""
    pass

但是模块呢?如何记录 file.py 的作用?

But what about a module? How can I document what a file.py does?

推荐答案

对于软件包,您可以记录放在 __ init __。py 中。
对于模块,您可以在模块文件中简单地添加文档字符串。

For the packages, you can document it in __init__.py. For the modules, you can add a docstring simply in the module file.

所有信息都在这里: http://www.python.org/dev/peps/pep-0257/

这篇关于如何在Python中记录模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆