python list 合并

[size=x-large]来自网络的代码:
[size=large]
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> A = [1, 2, 3]
>>> B = [4, 5, 6]
>>> A+B
[1, 2, 3, 4, 5, 6]
>>> A.extend(B)
>>> A
[1, 2, 3, 4, 5, 6]
>>> A.append(B)
>>> A
[1, 2, 3, 4, 5, 6, [4, 5, 6]]

猜你喜欢

转载自lixuan74.iteye.com/blog/1718280