python自定义函数(二)
来源:互联网 发布:淘宝佣金网 编辑:程序博客网 时间:2024/05/22 14:08
# -*- coding: cp936 -*-#给函数的参数设定预定值def test_function(val1,val2 = 20): #形参 有预定值的参数写到最右面,否则编译报错 print val1, #加,打印到一行 print val2 c = val1 + val2 return cprint 'entry programe!'s = test_function(3) #调用时只需要给未设置预定值的赋值print ss2 = test_function(3,12) #可以修改预设值print s2s3 = test_function(val1 = 4,val2 = 12) #可以通过参数名赋值print s3s4 = test_function(val2 = 12,val1 = 4) #可以通过参数名赋值 可以顺序与定义不同print s4''' s5 = test_function(val2 = 12, 4) #这样赋值会报错 pythonrint s5'''print 'put programe!'
0 0
- python自定义函数(二)
- Python列表操作自定义函数(二)
- python函数(二)
- python自定义函数(一)
- Python--函数,自定义函数
- split函数 (二) python
- python学习(二):函数
- Python学习(二 函数)
- Python中的函数(二)
- python中的函数(二)
- 【python】Python速成(二) --函数
- Python系列(二)之Python函数
- 自定义python自建类型(二)实战
- Transact-SQL 程序设计(二) --------自定义函数
- SQL Server自定义函数(二)
- Android 自定义View(二)函数分析
- Python学习(九)------- 自定义函数
- python 自定义函数。
- 关于cxf生成客户端代码中的JAXBElement<String>
- 机器学习中用到的各种距离
- AndroidNotification
- 第七周项目3-3
- AnnotationSessionFactoryBean和LocalSessionFactoryBean
- python自定义函数(二)
- 第七周习题练习记录
- WPF项目中使用柱状图、饼状图、折线图
- Node.js服务器环境搭建
- 聚集索引或非聚集索引使用
- Hdu 5064 Find Sequence(dp)
- 日志工具log4net试用记录
- Xshell命令
- 基于 Jenkins 快速搭建持续集成环境