发布时间:2019-09-12 07:58:26编辑:auto阅读(2729)
def test(id, ids=[]):
    if id:
        ids.append(id)
    print ids
test(id=1)
test(id=2)[1]
[1, 2]上面方法的定义方式跟下面是一样的,相当于是参数引用的是一个全局变量,所以它的值一直在累加
ids = []
def test(id, ids):
    if id:
        ids.append(id)
    print ids
test(id=1)
test(id=2)def test(id, ids=None):
    if id:
        ids = list()
        ids.append(id)
    print ids
test(id=1)
test(id=2)
上一篇: Python模拟登录和登录跳转
下一篇: python字典快速保存于读取
 51192
 50604
 41229
 38048
 32511
 29417
 28278
 23132
 23092
 21425
 1481°
 2197°
 1820°
 1749°
 2062°
 1811°
 2494°
 4187°
 4049°
 2891°