私信  •  关注

daniel mcgregor

daniel mcgregor 最近创建的主题
daniel mcgregor 最近回复了
6 年前
回复了 daniel mcgregor 创建的主题 » python文件路径&仅针对特定扩展名进行筛选

我不理解您的第二个问题,但要回答您的第一个问题,我发现检查文件类型的最简单方法是:

try:
        hierarchy['children'] = [
            path_hierarchy(os.path.join(path, contents))
            for contents in os.listdir(path)
                if file.endswith('.wav'):
                    # do something
        ]