什么是简约的pythonic非插入版本的扩展?我厌倦了写作
x = [ 1,2,3 ]
x.extend([4,5])
f(x)只是想:
f( x.extend( [4,5], inplace=False ) )或者其他什么
发布于 2014-09-30 16:38:51
使用+运算符怎么样?
def f(l):
return l
x = [1,2,3]
>>> id(x)
48474312 # Note the id
>>> x = f(x + [4,5])
[1, 2, 3, 4, 5]
>>> id(x)
43637016 # Different id, that means not in-placehttps://stackoverflow.com/questions/26125838
复制相似问题