Python - 连接2个列表

use*_*882 8 python list concatenation python-2.7

嗨,我是Python和这个论坛的新手.

我的问题:

我有两个清单:

list_a = ['john','peter','paul']
list_b = [ 'walker','smith','anderson']
Run Code Online (Sandbox Code Playgroud)

我使用以下方法成功创建了这样的列表zip:

list_c = zip(list_a, list_b)
print list_c
# [ 'john','walker','peter','smith','paul','anderson']
Run Code Online (Sandbox Code Playgroud)

但我正在寻找的结果如下:

list_d = ['john walker','peter smith','paul anderson']
Run Code Online (Sandbox Code Playgroud)

无论我尝试什么,我都没有成功!我怎么能得到这个结果?

the*_*eye 12

你从两个列表中得到压缩名称,只需加入每一对,就像这样

print map(" ".join, zip(list_a, list_b))
# ['john walker', 'peter smith', 'paul anderson']
Run Code Online (Sandbox Code Playgroud)


GWW*_*GWW 6

List_C = ['{} {}'.format(x,y) for x,y in zip(List_A,List_B)]
Run Code Online (Sandbox Code Playgroud)