如果想在 Python 中批量获取图像路径,可以使用以下代码:
import os
root_dir ="/path/to/images"
for subdir, dirs, files in os.walk(root_dir):
for file in files:
file_path = os.path.join(subdir, file)
if file_path.endswith(".jpg") or file_path.endswith(".png"):
print(file_path)
在上面