Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 无法将列表中的项目映射到列表列表中的列表_Python 3.x_List - Fatal编程技术网

Python 3.x 无法将列表中的项目映射到列表列表中的列表

Python 3.x 无法将列表中的项目映射到列表列表中的列表,python-3.x,list,Python 3.x,List,我有两张这样的名单 list1 = ['a','b','c','d'] list2 = [[20,30,15], [23,32,62,234, 234], [34,345,5345], [12]] 我如何映射它们以使其输出: a 20 a 30 a 15 b 23 b 32 b 62 . . . d 12 我试过这个 list1 = ['a', 'b', 'c', 'd'] list2 = [[20, 30, 15],

我有两张这样的名单

  list1 = ['a','b','c','d']
  list2 = [[20,30,15], [23,32,62,234, 234], [34,345,5345], [12]]
我如何映射它们以使其输出:

   a 20
   a 30
   a 15

   b 23
   b 32
   b 62
   .
   .
   .
   d 12 
我试过这个

list1 = ['a', 'b', 'c', 'd']
list2 = [[20, 30, 15], [23, 32, 62, 234, 234], [34, 345, 5345], [12]]
for item in list2:
    for al, it, in zip(list1, item):
        print(al, it)

a 20
b 30
c 15
a 23
b 32
c 62
d 234
a 34
b 345
c 5345
a 12
使用
枚举()


您是否可以:
[列表(zip(列表[0]*len(项目[1])、项目[1])中的项目(zip(列表1,列表2))]的列表(zip)(列表[0]*len(项目[1])),项目[1])]
list1 = ['a', 'b', 'c', 'd']
list2 = [[20, 30, 15], [23, 32, 62, 234, 234], [34, 345, 5345], [12]]
for index, alpha in enumerate(list1):
    for number in list2[index]:
        print(alpha, number)