摘要: def foo(l): l += 'b' l = 'abc' foo(l) print(l) #result 'abc' not 'abcb' l = ['abc'] foo(l) print(l) #result ['abc','b'] 作个总结,网上已经有相关的内容了,这里方便记忆。也许有理解错误的地方:) 先看后一种情况,python中的所有变量传递都是传递引用(感觉类似c中的指针,即... 阅读全文
posted @ 2009-09-11 19:19 阁子 阅读(4900) 评论(0) 推荐(0) 编辑