Python There are many functions , have access to help()
Function to get the usage of the function
help(print)
Help on built-in function print in module builtins:
print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
At the same time, when we define the function ourselves , You can also explain the function properly
def times(s:str,n:int) ->str: # The return value is str type
''' return n individual s character string '''
return s*n
print(times(' Beishan ',3))
Beishan, Beishan, Beishan
meanwhile , have access to .__annotations__
Method to get the type comment of the function
times.__annotations__
{'s': str, 'n': int, 'return': str}
He returns his two parameters in the form of a dictionary , And one. str Return value of type
View function documentation using .__doc__
Method
print(times.__doc__)
return n individual s character string
In object oriented programming ,python Class has multiple inheritance properties , If the inheritance relationship is too complex , It's hard to see which property or method will be called first .
In order to easily and quickly see the inheritance relationship and order , have access to .__mro__
class X(object):pass
class Y(object):pass
class A(X, Y):pass
class B(Y):pass
class C(A, B):pass
print C.__mro__
# (<class '__main__.C'>, <class '__main__.A'>,
# <class '__main__.X'>, <class '__main__.B'>,
# <class '__main__.Y'>, <type 'object'>)