'which'在Python中的等效函数 [英] 'which' equivalent function in Python
本文介绍了'which'在Python中的等效函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要通过运行'which abc'命令来设置环境。
'which'命令有python等效函数吗?
这是我的代码。
cmd = [which,abc]
p = subprocess .popen(cmd,stdout = subprocess.PIPE)
res = p.stdout.readlines()
如果len(res)== 0:return False
return True
解决方案有 distutils.spawn.find_executable 。
I need to setup environment by running 'which abc' command. Is there python equivalent function for 'which' command? This is my code.
cmd = ["which","abc"] p = subprocess.Popen(cmd, stdout=subprocess.PIPE) res = p.stdout.readlines() if len(res) == 0: return False return True
解决方案There is distutils.spawn.find_executable.
这篇关于'which'在Python中的等效函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文