python学习笔记
1. python中的整除: //
2. 在函数调用的过程中,进行参数的传递
如果是不可变对象,在函数体的修改不会影响实参的值
如果是可变对象,在函数体的修改会影响实参的值
3. 个数可变的位置形参:函数定义时,可变的位置参数,可变的位置参数个数只能是1个
结果:元素
def fun(*arg):
print(arg)
fun(10)
fun(10, 20)
4. 个数可变的关键字形参
结果:字典
def fun(**arg): print(arg) fun(a=11, b=22, c=33)
5. 在函数调用时,将列表中的每个元素都转化为位置实参传入
def fun(a, b, c): print("a=", a) print("b=", b) print('c=', c) list1 = [11, 22, 33] fun(*list1)