简明Python docstrings

 1 #!/usr/bin/env python
 2 #coding:utf-8
 3 def print_max(x,y):
 4     '''Prints the maximum of two numbers.打印两个数值中的最大数。
 5         The two values must be integers.这两个数都应该是整数'''
 6 #如果可能,将其转换至整数类型
 7 x=int(x)
 8 y=int(y)
 9 
10 if x>y:
11     print(x,'is maxinum')
12 
13 else:
14     print(y,'is maxinum')
15 
16 print_max(3, 5)
17 print(print_max.__doc__)
1 5 is maximum
2 Prints the maximum of two numbers.
3         The two values must be integers.
原文地址:https://www.cnblogs.com/jdy113/p/8052055.html