02 Python函数与模块

 • 函数是什么
 print()
 input()
 format()
 list()
 lower()
 upper()
 • 函数的定义
 def 函数名(形参1,2,3)
  函数体
 return
 • 函数的形参与实参
 
 
 • 函数使用技巧
  ○ 设置参数默认值
   § def 函数(形参="值")
  ○ 关键字传参
   § 函数(形参="值")   
  ○ 混合形式传参
   § def 函数(形参="值",*,形参2="值",形参3="值")    # 调用时*后面必须要使用关键字传参
  ○ 序列传参
   § def xxx1(a,b,c)
   
   § list1=[1,2,3]
   § xxx1(*list1)
  ○ 字典传参
   § dict1={"a":"v1", "b":"v2", "c":"v3"}
   § xxx1(**dict1)
  ○ 返回值包含多个数据
   § 返回字典

猜你喜欢

转载自www.cnblogs.com/ZZBD/p/12541459.html
今日推荐