Python函数
来源:互联网 发布:数据库中存储的是什么 编辑:程序博客网 时间:2024/05/17 09:08
函数参数
def say_hello():print('hello word')say_hello()say_hello()函数变量
def print_max(a,b):if a > b:print(a,'is max')elif a == b:print(b,'is equal to',a)else:print(b,'is max')print_max(3,4);x = 5y = 7print_max(x,y)函数默认值
def say(message,times=1):print(message * times)say('hello')say('word ',10)关键字参数
def func(a,b=5,c=15):print('a is ',a,'and b is',b,'and c is',c)func(3,7)func(25,c=24)func(c=25,a=100)可变参数
def total(a=5,*numbers,**phonebook):print('a',a)for single_item in numbers:print('single_item',single_item)for first_part,second_part in phonebook.items():print(first_part,second_part)print(total(10,1,2,3,Jack=123,Shon=4156151,Inge=151651561))return 语句
def max(x,y):if x > y:return x;elif x == y:return 'The numbers are equal';else:return y;print(max(2,3))DocStrings
def printf_max(x,y):'''Printfs ths max of two numbers. The two values must be integers. '''x = int(x)y = int(y)if x > y:print(x,'is max')else:print(y,'is max')printf_max(3,5)print(printf_max.__doc__)
阅读全文
0 0
- python函数
- python 函数
- python 函数
- Python 函数
- python 函数
- PYTHON函数
- python 函数
- Python函数
- python 函数
- Python 函数
- Python 函数
- Python 函数
- python函数
- python函数
- python 函数
- Python 函数
- Python函数
- Python函数
- 校园网络电视台直播搭建方案
- 图片的裁剪/优化
- 将Linux下编译的warning警告信息输出到文件中[整理笔记]
- Windows导出mysql表结构到word文档
- Spring+测试遇到的问题
- Python函数
- Android5.0新特性:RecyclerView实现上拉加载更多
- 蓝桥-ALGO-13-拦截导弹
- 深入理解Java 8 Lambda(类库篇——Streams API,Collectors和并行)
- LeetCode 173. Binary Search Tree Iterator
- 内存的堆分配和栈分配
- ASP.NET-Application对象
- 关于jsp的静态和动态引入文件问题
- PHP 实现四种基本排序算法