码迷,mamicode.com
首页 > 编程语言 > 详细

Python traps and pitfalls

时间:2015-01-04 22:46:37      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

@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 traps and pitfalls

标签:

原文地址:http://www.cnblogs.com/lxw0109/p/python-trips-and-pitfalls.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!