gpt4 book ai didi

python - 如何在 fnmatch.filter 中使用 OR 或 AND?

转载 作者:太空宇宙 更新时间:2023-11-03 13:26:17 24 4
gpt4 key购买 nike

如何在 fnmatch 过滤器中应用 OR 或 AND?

pattern = "*2006*|*2005*"
fnmatch.filter(list,pattern)

最佳答案

fnmatch 不支持(在一般情况下),语法非常有限 - 与 shell 风格的通配符相同。你必须使用 regular expressions ,或调用 filter 两次并合并结果(对于 OR)或将结果相交(对于 AND)。

关于python - 如何在 fnmatch.filter 中使用 OR 或 AND?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55172499/

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