Python 嵌套字典格式的输出问题

Python 嵌套字典格式的输出问题,python,gae-python27,Python,Gae Python27,我有以下嵌套字典: [[u'bob', u'fred'], [u'sanders', u'harris'], [u'bob@xyz.com', u'fredharris@abc.com'], ['user1 password', 'user2 password']] 打印我得到的密钥/值: 1:bob 1:fred 2:桑德斯 2:harris 三:bob@xyz.com 三:fredharris@abc.com 4:user1密码 4:user2密码 我无法在Python 2.7中找到获得以

我有以下嵌套字典:

[[u'bob', u'fred'], [u'sanders', u'harris'], [u'bob@xyz.com', u'fredharris@abc.com'], ['user1 password', 'user2 password']]
打印我得到的密钥/值:

1:bob
1:fred
2:桑德斯
2:harris
三:bob@xyz.com
三:fredharris@abc.com
4:user1密码
4:user2密码

我无法在Python 2.7中找到获得以下输出的方法:

bob[tab]sanders[tab]bob@xyz.com[tab]user1 password

fred[tab]harris[tab]fredharris@abc.com[tab]user2 password

您能帮助我吗?

这个片段应该可以解决您的问题:

mylist = [[u'bob', u'fred'], [u'sanders', u'harris'], [u'bob@xyz.com', u'fredharris@abc.com'], ['user1 password', 'user2 password']]

for i in range(len(mylist[0])):
    print '%s\t%s\t%s\t%s' % (mylist[0][i], mylist[1][i], mylist[2][i], mylist[3][i])

请注意,您的“嵌套字典”不是字典。

谢谢,我一定是错误地创建了它,试图使用pwords={}和循环pwords.setdefault(1,[]).append(fn)pwords.setdefault(2,[]).append(ln)pwords.setdefault(3,[]).append(em)不客气。如果你觉得这个答案有用,请考虑把它标记为一个被接受的答案。