你怎么知道你的python解释器在python中的位置?

Bri*_*tow 1 python

我有一个包含许多python版本的系统.有些是32b,有些64b,有些2.4有2.7,等等.我正在使用需要运行另一个python脚本的python脚本.我想用运行初始脚本的相同版本的python运行第二个脚本.

我的计划是做这样的事情:

os.system('%s script.py' % currentPython)
Run Code Online (Sandbox Code Playgroud)

问题是:我如何定义"currentPython"?

Sve*_*ach 5

可以访问python解释器的路径sys.executable.

请使用该subprocess模块调用子解释器,而不是os.system().