如何在 Python 中使用 glob lib 定位文件并打印它们

问题描述 投票:0回答:0

请告诉我这里出了什么问题,我已经在互联网上搜索了 3 天,但找不到解决方案。

import pandas as pd
import os
import glob

folder_name = input("Please insert the folder name to locate databases: ")
diskD = glob.glob("D:/*/{folder_name}/*.*".format, root_dir="D:", dir_fd=1, recursive=True)
inFilesD = glob.glob(diskD)
print(os.path.basename(inFilesD))

我尝试更改多行,希望程序能够找到特定的文件夹并打印出它的内容/文件

python glob
© www.soinside.com 2019 - 2024. All rights reserved.