当我想要实现我期望的结果时:
A:1
B:2
C:3
A:4-
B:5
C:6
并运行以下代码:
label_lst = ['A','B','C']
lst = [['1','2','3'],['4','5','6']]
for i in lst:
for j,k in label_lst,i:
print('{}:{}'.format(j,k))
追溯输出:
ValueError:解压缩的值太多(预期2)
是否有任何模块或密钥可以修复我的错误?
答案 0 :(得分:3)
for sublist in lst:
for i,j in zip(label_lst, sublist):
print('{}:{}'.format(i,j))
产生
A:1
B:2
C:3
A:4
B:5
C:6