Home > Backend Development > Python Tutorial > 'Python Basics Tutorial' Notes Abstraction

'Python Basics Tutorial' Notes Abstraction

黄舟
Release: 2016-12-20 17:24:26
Original
1184 people have browsed it

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 (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template