装饰器前奏2(2017年8月23日 11:50:39)(2017年8月29日 16:07:32)

本文介绍了Python中函数的基本概念,包括如何定义和调用函数,以及匿名函数(lambda表达式)的使用方法。通过具体示例展示了匿名函数的定义与调用过程。

 

门牌号的作用是让人找到这个房间

门牌号没有的话 就会清空里面的内容(python的内存回收机制)

函数就是变量

 

匿名函数(没有函数名)

calc = lambda x:x*3

print(calc(3))

 

 

 

函数只要定义了,就能调用。

函数就是一种变量(加引号的变量)

# def foo():
#     print('in the foo')
#     bar()
# foo()

#只要定义了,就能调用
def bar():
    print('in the bar')
def foo():
    print('in the foo')
    bar()
foo()


def foo():
    print('in the foo')
    bar()
def bar():
    print('in the bar')
foo()


# def foo() # print('in the foo') # bar() # foo() # def bar() # print('in the bar')

 

转载于:https://www.cnblogs.com/yeison/p/7419476.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值