# 下面代码会输出什么:
def f(x,li=[]):
for i in range(x):
li.append(i*i)
print(li)
f(2) #[0, 1]
f(3,[3,2,1]) # [3,2,1,0,1,4]
f(3) #[0,1,0,1,4] 此时li是[0,1]
时间: 2024-12-14 15:13:34
# 下面代码会输出什么:
def f(x,li=[]):
for i in range(x):
li.append(i*i)
print(li)
f(2) #[0, 1]
f(3,[3,2,1]) # [3,2,1,0,1,4]
f(3) #[0,1,0,1,4] 此时li是[0,1]