gpt4 book ai didi

python - 删除两个列表之间的公共(public)元素

转载 作者:太空狗 更新时间:2023-10-29 20:33:13 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Python list subtraction operation

我想删除两个列表之间的公共(public)元素。我的意思是这样的


a=[1,2,3,4,5,6,7,8]
b=[2,4,1]
# I want the result to be like
res=[3,5,6,7,8]

有什么简单的 pythonic 方法可以做到这一点吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com