python - 查找程序的路径(python)
问题描述
所以我正在尝试查找可执行文件的路径,现在我的代码正在检查每个目录,所以感觉不是最好的选择,可能需要一些时间进行一些搜索
def findFile(filename):
newFileName=filename+'.exe'
for root,dirs, files in os.walk("C:\\"):
for f in files:
if newFileName in os.path.join(root,f).lower() and "install" not in os.path.join(root,f).lower():
return os.path.join(root,f)
return None
所以我正在寻找不包含单词 install 的 exe 文件,因为我现在只想启动程序任何建议以使其更有效
解决方案
推荐阅读
- java - How to fix jOOQ code generation tool error?
- linux - 从具有父目录的每个子文件夹中复制特定文件
- javascript - PortQry 与 ElectronJS 桌面应用程序的集成
- c# - 尝试在 SignalR 内的组中添加客户端但不工作
- java - 科特林。Java 和 PHP 性能与 MySQL
- android - ConstraintLayout android中的链接链
- typo3 - 如何将字符串与 TYPO3 Fluid 中的变量进行比较
- linq - linq多对多,如何清除“加入”表?
- apache - 如何从虚拟主机将 http 重定向到 ubuntu 中的 https?
- android - webview中的虚拟键盘重叠输入