python-3.x - 有没有办法在 python 中使用带有 subprocess.call() 的 shell 脚本
问题描述
我在下面找不到此问题代码的解决方案:
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'
解决方案
好吧,我有点累了 答案是
subprocess.call(['./eu_presun.sh']**,shell=True**)
我也有这个地址的问题,我不得不添加完整路径
推荐阅读
- .net-core - Entity Framework Core 3.1 如何从另一个表中按字段排序
- python - 如何检索最小和最大余弦?
- php - 如何根据数据库中的值给 SVG 圆一个笔划?
- awk - 使用 awk 进行 vlookup:如何将组/模式与 id 匹配
- sql - Oracle 中的 GROUP BY 失败
- c# - 在 SSIS 中合并 .dtsx 文件
- arrays - 如何获取这些数组并使用它们来填充结构的字段?
- racket - 尝试在具有两个“相互递归”方法的特征的覆盖方法之外调用“super”,但失败了
- sql - 具有硬编码值的子查询的 LEFT OUTER JOIN 错误
- python - 没有正确输入数字 python selenium