python documentation string (function instructions)

Keywords: Function Description, help () function

1. FIG Effect:

2. Code:

# Documentation string (doc str) is a function of instructions 
# usage: write a string in the first line of the function 
DEF the Fn (* nums):
     '' '
    The action function: calculating the sum of any number
    Function parameters: * nums accepts all values ​​passed in, saved to a tuple (-pack)
    '' ' 
    Print (the nums, type (the nums))
     # define a variable, to save sum 
    Result = 0
     for n- in the nums:
        result += n
    return result
print(fn(2,5,7,8))

Expansion: help () function  

  Renderings:

    Custom Query function usage

 

 

 

 

    Built-in query python print () function usage

 

Guess you like

Origin www.cnblogs.com/FlyingLiao/p/11267223.html