有一种方法可以在python内部通过subprocess.call()使用shell脚本。

问题描述 投票:0回答:1
我在下面找不到此问题代码的解决方案:

import subprocess subprocess.call(['./eu_presun.sh'])

shell脚本与main.py位于同一目录中,我将使用python,然后我要使用此shell脚本我收到此错误。

Traceback (most recent call last): File "~/_main.py", line 304, in <module> subprocess.call(['sh eu_presun.sh']) File "/usr/lib/python3.8/subprocess.py", line 340, in call with Popen(*popenargs, **kwargs) as p: File "/usr/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: './eu_presun.sh'

我在下面找不到此问题代码的解决方案:import subprocess subprocess.call(['./ eu_presun.sh'])Shell脚本与main.py位于同一目录中,我将使用python,然后要使用它shell ...
python-3.x shell subprocess
1个回答
0
投票
好吧我有点累答案是
© www.soinside.com 2019 - 2024. All rights reserved.