我有一个扩展名为.run的文件,例如myfile.run。它是可执行的,即权限级别设置正确。在
在Linux终端中,我可以通过提交./myfile.run来执行它。在
在Python3.6中,我尝试使用subprocess.run()函数执行同一个文件,但没有成功。:(我试过:result = subprocess.run( ['./home/user1/myfile.run'], stdout=subprocess.PIPE )
Traceback (most recent call last):
File "", line 1, in
result = subprocess.run( [a], stdout=subprocess.PIPE )
File "/usr/lib/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: './home/user1/myfile.run'
我试过了:
^{pr2}$
以及result = subprocess.run( '/home/user1/myfile.run', stdout=subprocess.PIPE, shell=True )
什么也没发生。在
我应该使用什么正确的subprocess.run()语法?谢谢。在