python - Subprocess, Launch script in alternate version of Python
问题描述
My main script, main.py
runs in python3. within it, I want to launch another script in some specified version of python.
import subprocess
pysh="/data/data/org.qpython.qpy/files/bin/qpython-android5.sh"
subprocess.call([pysh,'filetext.py'])
Question:
How can I use subprocess to open filetext.py
in python2.x or 3.x interchangeably?
I have tried:
I have tried inputting several different arguments to no avail, such as:
os.system('python -2 -m filetext.txt')
or
subprocess.call(['py -2 filetext.txt'])
or
subprocess.call(['C:/Python27/python.exe filetext.txt'])
Any help would be immensely appreciated.
解决方案
尝试这个 :
subprocess.call(['C:/Python27/python.exe', "filetext.txt"])
首先给出所需可执行文件的路径,然后给出不同参数中的参数。
推荐阅读
- r - 基于频率的子集数据框
- c++ - 无法从 Win32_OperatingSystem 类中获取“描述”
- html - 我如何在 html 中使用 ()
- javascript - 从不同的值数组创建对象数组
- python - 排序数据,django 上的 Paginator
- c++ - 在类的构造函数中使用“this”关键字与在 C++ 中不使用它有区别吗
- common-lisp - 为什么根据这本书,CL中两个“非”函数的函数组合会导致nil?
- awk - 如何使用 awk 或 sed 获取部分匹配之间的所有行?
- git - 执行硬重置后如何将开发分支推送到远程存储库?
- javascript - 为什么当我加载页面时我的 scrollBy 似乎不起作用,尽管它通过了低谷?尽管第二次进入 hashchange 它工作