您好,欢迎来到比熊情感。
搜索
您的当前位置:首页《python基础教程》笔记之抽象

《python基础教程》笔记之抽象

来源:比熊情感


创建函数

记录函数,在函数的开头写下字符串,它就会作为函数的一部分进行存储,这称为文档字符串,如

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

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

help -- 在交互式解释器中使用会得到关于函数包括它的文档字符串的信息,如

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

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

所有的函数都返回了东西:当不需要它们返回值的时候,它们就返回None。

参数魔法

Copyright © 2019- bxjq.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务