subprocess
打开特定的本地或网络目录,以及使用特定字符串搜索图像文件名。os
或搜索Windows pathlib
。在python中查找文件中明确说明了这些方法indexed
Windows
Control Panel
了Indexing Options
import subprocess
query_string = 'file_name.png'
local_path = r'C:\Users\your_name\Pictures' # r is raw for dealing with backslashes
network_path = r'\\your\network\fold\path'
# for a network location
subprocess.Popen(f'explorer /root,"search-ms:query={query_string}&crumb=location:{network_path}&"')
#for a local folder
subprocess.Popen(f'explorer /root,"search-ms:query={query_string}&crumb=folder:{local_path}&"')
f'some_string {variable}'
来自PEP498:格式化字符串文字。explorer
&/root
是Windows命令。本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句