python 函数小结
来源:互联网 发布:浙江师范行知学院宿舍 编辑:程序博客网 时间:2024/05/20 11:48
1.函数只有被调用才能使用
2. 输入的参数名不能有重名,并且需要有RETURN 返回值
3.常用的函数打印描述:
print test2.__doc__
var.append('ddd');原来的基础上增加字符串
一: 函数参数是字典的形式(变量名与值)
>>> def test2(**z):return z
>>> print test2(a=1,b=2,c=3)
{'a': 1, 'c': 3, 'b': 2}
运行结果如下:
四:列表的形式返回
return z
>>> print test3(1,2,3)
(1, 2, 3)
二: 通常的做法位置参数,需要输入全部的参数
>>> def mytest(a,b,c):
return a + b + c
>>> mytest(1,2,3)
6
三:可选的参数: 需要定义值
>>> def test(a=3,b=4,c=5):
return a + b +c
>>> print test()
12
>>> print test(a=10)
19
>>>
0 0
- python 函数小结
- python 函数小结
- Python字符串函数小结
- Python strip 函数小结
- [python] 函数小结
- python函数小结归纳
- Python-基础-内置函数小结
- Python 内建函数小结
- python学习小结3:函数
- python 文件和路径操作函数小结
- python 文件和路径操作函数小结
- python 文件和路径操作函数小结
- python 文件和路径操作函数小结
- python 文件和路径操作函数小结
- python 文件和路径操作函数小结
- python中sort和sorted函数小结
- python文件和路径操作函数小结
- python中的一些类型转换函数小结
- 有序矩阵中查找第k小的元素 Kth smallest element in a row-wise and column-wise sorted 2D array
- [leetcode] Decode Ways
- Remove Duplicates from Sorted List II
- Reverse Linked List
- appcompat_v7 与 actionbarsherlock 冲突解决/移除项目中的appcompat_v7
- python 函数小结
- R apply, lapply, sapply, mapply, tapply functions
- OpenWrt的差异化特性介绍
- Reverse Linked List II
- 接口设备发包
- js表中验证常用正则表达式
- 用Intel HAXM加速Android Emulator
- 人脸识别以及漫画效果处理
- 将中、英文字号转变为像素