learning python--Docstrings使用
来源:互联网 发布:mac地址计算pin码软件 编辑:程序博客网 时间:2024/05/16 12:55
One-Line Docstrings
example :
def add(x, y): """Return the sum of two numbers.""" return x + y
print add._doc_
Multi-Line Docstrings
example :Listing 1def subtract(x, y): """Return the difference between two numbers. Arguments: x -- The minuend. y -- The subtrahend. Returns: A number, the difference between x and y (ie. x - y) """ return x - ysubstract(5,2)
print substarct_doc_
Listing 2
#!/usr/bin/env python"""A simple math module.Exported Classes:Math -- A simple math class with mathematical functions."""class Math(object): """A simple math class with mathematical functions. Public functions: add -- Adds two numbers together and returns the result. subtract -- Returns the difference between two numbers. """ def subtract(self, x, y): """Return the difference between two numbers. Arguments: x -- The minuend. y -- The subtrahend. Returns: A number, the difference between x and y (ie. x - y) """ return x - y def add(self, x, y): """Return the sum of two numbers. Arguments: x -- Number to be summed. y -- Number to be summed. Returns: A number, the sum of x and y (ie. x + y) """ return x + y
print add(4,5)
print add_doc_
www.learningpython.com/2010/01/08/introducing-docstrings/
- learning python--Docstrings使用
- Python docstrings
- 使用DocStrings为python函数添加注释
- Python中的DocStrings
- python中的DocStrings
- docstrings
- DocStrings
- DocStrings
- Python DOCStrings示例程序
- Python随笔之文档字符串(DocStrings)
- 【python coding 6:文档字符串】Python的文档字符串DocStrings
- 简明python教程学习笔记之十-DocStrings文档字符串
- GoodZhang在学Python(五)--Python中的文档字符串(docStrings)
- 【脚本语言系列】关于Python测试工具docstrings, 你需要知道的事
- Learning Python
- Learning Python
- Learning Python
- Learning Python
- 算法-插入排序
- Android手机真机调试
- mysql多台服务器数据同步
- 非阻塞式socket编程select()
- php中echo(),print(),print_r()的区别
- learning python--Docstrings使用
- [转]取标准时间 // 中国国家授时中心的IP地址是:210.72.145.44
- ASP.NET跨页面传值技巧总结
- DWORD GetTickCount OS启动到现在的毫秒数
- 斯蒂夫·乔布斯给年轻人的十一句金玉良言
- Samba配置文件常用参数详解
- 生成activex控件的方法
- 用于C/C++的繁简转换头文件
- 存储过程实现业务与java分层实现业务比较