Python,使用glob列出图像,使用变量时为空列表

问题描述

我正在尝试使用 glob 获取目录中的图像列表

我有两种方法,第一种有效,但第二种无效

from pathlib import Path
jpgs = list(Path('X:\\path\\to\\directory').rglob("*.[jJ][pP][gG]"))

第二个将目录作为 image_path 中的字符串开始

image_path = 'X:\\path\\to\\directory'
jpgs = list(Path(image_path).rglob("*.[jJ][pP][gG]"))

我不明白为什么第二个返回一个空列表,有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)