python define function

>>> def square(x):
...     'calculates the square of the number x.'
...     return x*x
... 
>>> square.__doc__
'calculates the square of the number x.'
>>> help(square)
Help on function square in module __main__:

square(x)
    calculates the square of the number x.

猜你喜欢

转载自www.cnblogs.com/lianghong881018/p/11080772.html