2007年02月14日 星期三 17:03
ÎÒÕýÔÚ¿´¡¶¼òÃ÷ Python ½Ì³Ì¡·£¬ÆäÖÐÒ»ÀýÈçÏ£º Àý7.8 ʹÓÃDocStrings #!/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. µ«ÊÇÎÒÔËÐÐʱ£¬È´µÃµ½ÈçÏ»ØÏÔ£º 5 is maximum Traceback (most recent call last): File "D:\Python25\func_doc.py", line 16, inprint printMax._doc_ AttributeError: 'function' object has no attribute '_doc_' googleÁËһϣ¬Ã»ÓÐÕÒµ½´ð°¸£¬msÕâλÐÖµÜ<http://mailman.linuxchix.org/pipermail/techtalk/2004-April/018394.html> Ò²ºÍÎÒÊÇͬһ¸öÎÊÌâ Çë´ïÈ˴ͽ̣¬thx -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070214/b7ae6dcc/attachment.html
Zeuux © 2025
京ICP备05028076号