Python_day08_01.txt 571 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. Python_day08_01
  2. 1. def foo():
  3. return
  4. 2. def foo(name, age=18): # 形参 name位置参数, age默认参数
  5. print(name)
  6. return age
  7. f = foo('xdc',19)
  8. print(r)
  9. xdc
  10. 19
  11. foo(age=18, name='xdc')
  12. 3.万能参数
  13. def foo(*args, **kwargs):
  14. args
  15. kwargs
  16. 4.格式化输出
  17. tmp = "{}-{}"
  18. s = tp.format(3,4)
  19. ###============ 今日内容 ============###
  20. 高级函数
  21. 1、函数的传参是引用附值
  22. 1.1 定义一个必须传递的关键字参数
  23. 2、名称空间和作用域
  24. 3、内部函数
  25. 4、闭包
  26. 5、装饰器