python--函数
来源:互联网 发布:数据库用来做什么 编辑:程序博客网 时间:2024/05/22 03:41
print('第一个function--python')
>>> MyFirstFunction()
第一个function--python
>>>
>>> def MyFirstFunction():
print('第一个function--python')
>>> MyFirstFunction()
第一个function--python
>>> def add(num1,num2):
res = num1 + num2
print(res)
>>> add(1,2)
3
>>> def add(num1,num2):
return num1 + num2
>>> res = add(5,6)
>>> res
11
>>>
>>> def ceshi(my,world):
return my + world
>>> myworld = ceshi(world = 'zhongguo world',my = 'mymy')
>>> print(myworld)
mymyzhongguo world
>>>
>>> def test(*params):
print('参数长度',len(params));
print(params);
print('dierge canshu ',len(params[1]))
>>> test(1,'ceshi',3,4,5)
SyntaxError: unexpected indent
>>> test(1,'ceshi',3,4,5)
参数长度 5
(1, 'ceshi', 3, 4, 5)
dierge canshu 5
>>> def FunX(x):
def FunY(y):
return x * y
return FunY
>>> i = FunX(8)
>>> type(i)
<class 'function'>
>>> FunX(8)(7)
56
>>>
python 匿名函数
>>> g = lambda x : 2 * x + 1
>>> g(5)
- python函数
- python 函数
- python 函数
- Python 函数
- python 函数
- PYTHON函数
- python 函数
- Python函数
- python 函数
- Python 函数
- Python 函数
- Python 函数
- python函数
- python函数
- python 函数
- Python 函数
- Python函数
- Python函数
- PHP拦截器
- 使用SVN过程中遇到的奇葩问题
- opencv学习(二十六)之图像金字塔(高斯金字塔、拉普拉斯金字塔)
- 电脑bluescreen蓝屏解决方法
- PHP - Curl的302是什么鬼
- python--函数
- CAMERA学习(一)-------跟踪应用层到HAL
- 执行后台耗时操作的封装-----改进版
- You must use a newer version of the Android Gradle plugin. The minimum supported version is 0.12.0 a
- maven 将依赖jar包打包
- cstring和string的区别
- 多线程-9、dispatch源
- grpc+protobuf 的C++ service 实例解析
- 极光推送 使用实例 (一)服务端