【问题标题】:Find the pattern inside the file name in python在python中查找文件名中的模式
【发布时间】:2021-07-22 07:28:07
【问题描述】:

我有具有特定名称的数据库。我需要迭代数据库记录并找到具有适当模式的记录。 例如: 带通配符的模式: abc.*.cde 文件名: abc.123.cde

如何检查名称“abc.123.cde”是否是模式“abc.*.cde”的一部分?

【问题讨论】:

    标签: python python-3.x string


    【解决方案1】:

    看来我必须使用 fnmatch 模块:

    fnmatch.fnmatch(files, 'abc.*.cde')
    

    将根据模式将文件返回给我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-18
      • 2012-03-06
      • 1970-01-01
      • 2012-07-24
      • 2020-12-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多