| ???? Python ??? | ??7?? ???? | |
|---|---|---|
| ???? | DocStrings | ???? |
Python???????????????????? ???????? ????????????? docstrings ??DocStrings???????????????????????????????????????????????t????????????????????????????§Ö??????????????????????
#!/usr/bin/python
# Filename: func_doc.py
def printMax(x, y):
'''Prints the maximum of two numbers.
The two values must be integers.'''
x = int(x) # convert to integers, if possible
y = int(y)
if x > y:
print x, 'is maximum'
else:
print y, 'is maximum'
printMax(3, 5)
print printMax.__doc__
????????code/func_doc.py??
$ python func_doc.py
5 is maximum
Prints the maximum of two numbers.
The two values must be integers.
???????????????§Ö????????????????? ???????? ?????DocStrings?????????????????????????????????????????
????????????????????????????????????????§Õ????????????¦Â???????????§µ???????§á??????????????? ?????? ????????????????????????????????????
????????__doc__????????????????printMax???????????????????????????????????????Python?? ???????? ???????????????????????????????????????????????????????
??????????Python????¨´?help()????????????????DocStings???????????????????????????__doc__??????????????????????????????????????????????????????????§Ñ???help(printMax)???????q???help??
??????????????????????????????????????????????? ?????? ???????§Õ???¦Ê??????????§Õ???????????????Python???§Ñœ…????pydoc??????help()????????DocStrings??
| ???? | ????? | ???? |
|---|---|---|
| return??? | ??? | ???? |