2020年4月16日 星期四

(轉) Python Docstrings

Python Docstrings

(Multiple line comments, pro tips)

def my_function():
    """Demonstrate docstrings and does nothing really."""
   
    return None
  
print "Using __doc__:"
print my_function.__doc__
  
print "Using help:"
help(my_function)
Output:
Using __doc__:
Demonstrate docstrings and does nothing really.
Using help:
Help on function my_function in module __main__:

my_function()
    Demonstrate docstrings and does nothing really.

沒有留言:

張貼留言