Tre*_*ney 5 python windows explorer subprocess popen
subprocess打开特定的本地或网络目录,并搜索具有特定字符串的图像文件名。ospathlibindexedWindows
Control PanelIndexing Optionsimport 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}&"')
Run Code Online (Sandbox Code Playgroud)
f'some_string {variable}'来自 PEP498:格式化字符串文字。explorer& /root是 Windows 命令。| 归档时间: |
|
| 查看次数: |
3855 次 |
| 最近记录: |