Home  >  Article  >  Backend Development  >  "Python Basics Tutorial" Notes Abstraction

"Python Basics Tutorial" Notes Abstraction

黄舟
黄舟Original
2016-12-20 17:24:261128browse

Create a function

Document the function, write a string at the beginning of the function, it will be stored as part of the function, this is called a documentation string, such as

def square(x): 'Caculates the square of the number x.'
return x*x

>>> square.__doc__
'Caculates the square of the number x.'

help -- used in the interactive interpreter will get information about the function including it Document string information, such as

>>> help(square)
Help on function square in module __main__:

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

All functions return Something else: When their return value is not required, they return None.

Parameter Magic

The above is the abstract content of the notes of "Python Basic Tutorial". For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn