首页 > 解决方案 > 如何编辑参数格式

问题描述

我有一个 python 脚本......它的调用方式与 bash 不同

./script.py 'arg1' 'arg2 stillarg2'

在 python 脚本中有两个参数。

现在我想用 bash 脚本调用它

#!/bin/bash
./script.py ${1} ${2} ${3}

我想用这种语法调用 bash 脚本

./script.sh arg1 arg2 stillarg2

在 Bash 脚本中有 3 个参数并且没有引号。

那么有没有一种方法可以通过使用 bash 脚本来调用带有参数的 python 脚本。没有引号和 3 个参数?

我试过了:

#!/bin/bash
./script.py "'${1}'" "'${2} ${3}'"

结果是:

operation not support

标签: pythonbashargumentsshquotes

解决方案


你只是想在同一个论点中结合$2和,不是吗?$3

#!/bin/bash
./script.py "${1}" "${2} ${3}"

推荐阅读