从列表中删除重复项,并带有多个列表

发布于 2025-02-02 20:08:13 字数 168 浏览 2 评论 0原文

我有一个带有多个列表的列表。该列表看起来像这样:

[[[名称,过程],[Name2,Process],[name,Process1]]

我正在尝试删除具有重复名称的列表(允许重复的过程),我不知道如何我迭代所有列表的第一个索引以删除重复项。

有人可以帮忙吗?

多谢

I have a list with multiple list. The list looks something like that:

[[ Name , Process], [Name2, Process] , [Name, Process1]]

I'm trying to remove Lists with a duplicate Name (duplicate Processes are allowed) and i don't know how i iterate through the first index of all Lists to remove the duplicates.

Can somebody help?

Thanks alot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

窝囊感情。 2025-02-09 20:08:13

关于输入和输出要求是什么,我认为这可能有效:

list_ = [['Name', 'Process'], ['Name2', 'Process'], ['Name', 'Process1']]

d = {}

for n, p in list_:
    d.setdefault(n, p)

print([[k, v] for k, v in d.items()])

输出:

[['Name', 'Process'], ['Name2', 'Process']]

Making several assumptions about what the input and output requirements are, I think this may work:

list_ = [['Name', 'Process'], ['Name2', 'Process'], ['Name', 'Process1']]

d = {}

for n, p in list_:
    d.setdefault(n, p)

print([[k, v] for k, v in d.items()])

Output:

[['Name', 'Process'], ['Name2', 'Process']]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文