【发布时间】:2017-04-26 19:40:57
【问题描述】:
假设我有一个这样的 Python 字典:
GroupName [('G:', 'G:/path/to/folder1', 'Full Access'), ('G:', 'G:/path/to/folder2', 'Full Access'), ('G:', 'G:/path/to/folder3', 'Full Access')]
如何循环遍历它以在新行上打印每个条目,如下所示:
GroupName G:/path/to/folder1 Full Access
GroupName G:/path/to/folder2 Full Access
GroupName G:/path/to/folder3 Full Access
我知道你可以做到
for k,v in GroupName.items:
print k,v
导致
GroupName [('G:', 'G:/path/to/folder1', 'Full Access'), ('G:', 'G:/path/to/folder2', 'Full Access'), ('G:', 'G:/path/to/folder3', 'Full Access')]
但我不确定如何进一步解析 v 以单独打印值。
我们将不胜感激。
谢谢!
【问题讨论】:
-
那不是字典。字典有大括号和冒号。
-
@ChrisC
type是什么组搜索? -
@af3ld 是字典类型
标签: python dictionary tuples