为什么当我在第 4 行中放入方括号时输出发生变化?
def x(a, b):
d = []
for i in range(0, a):
d += str(i) + b
return d
c = x(3, "7")
print(c)
输出:
['0', '7', '1', '7', '2', '7']
def x(a, b):
d = []
for i in range(0, a):
d += [str(i) + b]
return d
c = x(3, "7")
print(c)
输出:
['07', '17', '27']
为什么输出会这样改变?
肥皂起泡泡
相关分类