对使用 for 获取的字典中的项目重新排序
我有一本看起来像这样的字典:
Test = {"list_0" : ["a","b","c"],
"list_1" : ["e","f","g"],
"list_2" : ["h","i","e"],
"list_3" : ["f","g","h"],
"list_4" : ["i","l","m"]}
for list_n, Letter in Test.items():
# print (Letter)
print (list_n)
for s in Letter:
print (s)
我想更改选择项目的顺序:
示例 1:list_0, 1, 3, 4 示例 2:List_1, 2, 3 ,0 ... 直到完成所有可能的组合。
我尝试过这样做,但我不确定我走的路是否正确。
I have a dictionary that looks like this:
Test = {"list_0" : ["a","b","c"],
"list_1" : ["e","f","g"],
"list_2" : ["h","i","e"],
"list_3" : ["f","g","h"],
"list_4" : ["i","l","m"]}
for list_n, Letter in Test.items():
# print (Letter)
print (list_n)
for s in Letter:
print (s)
I would like to change the order in which the items are chosen:
example 1: list_0, 1, 3, 4
example 2: List_1, 2, 3 ,0
...
Until all possible combinations have been completed.
I've tried doing this but I'm not sure I'm going the right way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我已经找到了您问题的答案:
输出:
或者,如果您正在寻找这四个列表的每种可能的组合:
输出:
请告诉我我是否正确解释了您的问题。
I think I have the answer to your question:
Output:
OR if you're looking for every possible combination of these four lists:
Output:
Please Tell me if I interpreted your question correctly.