xiaozi 2014-11-24 22:38:00

python 中,应当避免参数默认值使用list或dict等,因为默认参数会在函数定义的时候就被初始化。

python python
# encoding: utf-8

def hello(someone = {}):
	print(someone);
	someone['name'] = 'aa'
	
if __name__ == '__main__':
	hello()
	hello()

评论

首页 - Wiki
Copyright © 2011-2025 iteam. Current version is 2.142.1. UTC+08:00, 2025-04-03 15:11
浙ICP备14020137号-1 $访客地图$