您的位置:首页 > 编程语言 > Python开发

Python中print(__doc__)作用的教程

2017-07-11 09:57 369 查看

作用

输出文件开头注释的内容

推广

1)momodule.py

"""This is the module docstring."""

def f(x):
"""This is the function docstring."""
return 2 * x


2)执行

>>> import mymodule
>>> mymodule.__doc__
'This is the module docstring.'
>>> mymodule.f.__doc__
'This is the function docstring.'


参考资料

print(doc) in Python 3 script
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python