这是我目前的代码
from subprocess import call
call("/Users/oscar/Desktop/Controlled Assessment/Currency Converter.py")
当我运行它时,我收到此错误消息
Traceback (most recent call last):
File "/Users/oscar/Desktop/Controlled Assessment/ISBN Checker.py", line 10, in <module>
call("/Users/oscar/Desktop/Controlled Assessment/Currency Converter.py")
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 470, in call
return Popen(*popenargs, **kwargs).wait()
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 744, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/subprocess.py", line 1394, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
答案 0 :(得分:2)
由于您似乎正在尝试执行另一个Python脚本,为什么不导入它呢?
import Currency_Converter
然后在那里运行你想要的模块?从文件名中取出空格,并用下划线替换它。
答案 1 :(得分:0)
从脚本中检查解释器指令。
它应该以:
开头#!/usr/bin/env python
print 'your python script...'
这意味着当你直接调用这个脚本时,它将被python二进制解释。
上获得更多信息答案 2 :(得分:0)
使用subprocess.Popen
import sys, subprocess
subprocess.Popen([sys.executable, "myscript.py"])
这应该在Python命令行中运行myscript.py
。