[Python] python 使用函数默认值来实现函数静态变量的功能 →→→→→进入此内容的聊天室

来自 , 2019-11-22, 写在 Python, 查看 118 次.
URL http://www.code666.cn/view/dd325446
  1. def f(a, L=[]):
  2.     L.append(a)
  3.     return L
  4.  
  5. print f(1)
  6. print f(2)
  7. print f(3)
  8. print f(4,['x'])
  9. print f(5)
  10.  
  11.  

回复 "python 使用函数默认值来实现函数静态变量的功能"

这儿你可以回复上面这条便签

captcha