@1: 

>>> def func(a, L=[]):
...     L.append(a)
...     print(L)
...
>>> func(10)
[10]
>>> func(20)
[10, 20]

 如果你不理解上面的代码的输出,可以参考下面的文章 

【陷阱!】Python可变缺省参数: http://blog.csdn.net/imzoer/article/details/8686738

 @2:

Python 程序员最常犯的十个错误: http://www.codeceo.com/article/10-mistake-python-programmer.html

 

相关文章:

  • 2021-11-23
  • 2022-01-20
  • 2022-12-23
  • 2022-02-03
  • 2021-11-14
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-30
  • 2021-05-21
  • 2021-09-24
  • 2021-10-25
  • 2022-02-20
  • 2021-06-06
  • 2021-12-10
相关资源
相似解决方案