Python中文
首页
教程
问答
标签
搜索
登录
注册
从bash scrip向python传递参数
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我一直在研究<code>bash</code>和{<cd2>}脚本的混合脚本。bash脚本可以接收未知的count输入参数。例如:</p> <pre><code>tinify.sh test1.jpg test2.jpg test3.jpg ..... </code></pre> <p>bash接收到all之后,将这些参数传递给<code>tinify.py</code>。现在我想出了两种方法。在</p> <ul> <li><p>在<code>bash</code>中循环并调用<code>python tinify.py testx.jpg</code></p> <p>换句话说,<code>python tinify test1.jpg</code>然后<code>python tinify test2.jpg</code>,最后<code>python tinify test3.jpg</code></p></li> <li><p>将所有参数传递给<code>tinify.py</code>,然后在<code>python</code>中循环</p></li> </ul> <p>但有一个问题,我想过滤相同的参数,例如如果用户输入<code>tinify.sh test1.jpg test1.jpg test1.jpg</code>,我只想要<code>tinify.sh test1.jpg</code>,所以我认为用第二种方法比较容易,因为python可能比较方便。在</p> <p><strong>如何将所有参数传递给python脚本?</strong>提前谢谢!在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>在<code>tinify.sh</code>中使用<code>$@</code></p> <pre><code>#!/bin/bash tinify.py "$@" </code></pre> <p>在Python脚本中消除重复项(从shell中过滤出来)会容易得多。(当然,这就产生了一个问题:您是否需要shell脚本。)</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何用强化学习更新函数逼近中的权重?
8 回答
如何用归并排序计算倒数?
2 回答
如何用当前数据拟合正弦波?
9 回答
如何用当前页面的值填充表单?
4 回答
如何用彩色地图在2dpython直方图中勾勒出箱子的轮廓?
3 回答
如何用彩色地图给等高线标签上色?
2 回答
如何用彩色打印到控制台?
10 回答
如何用彩色条绘制2d直方图,在Python中显示第三个变量的平均值?
8 回答
如何用彩色条绘制直方图,其中的颜色应与xaxis中的值一致?
5 回答
如何用彩色贴图填充曲线和原始边之间的区域?
7 回答
如何用循环分割数组并对其应用操作?
3 回答
如何用循环创建多个子集的数据帧
6 回答
如何用循环和递归实现求和
4 回答
如何用循环填充数组?
6 回答
如何用循环当前引用的位置更新变量?
4 回答
如何用循环求这个级数的和
7 回答
如何用循环解这个方程?
7 回答
如何用循环语句逐个读取数据帧中的数据?
6 回答
如何用循环除法?(Python)
3 回答
如何用感知一致性对HSV空间进行采样
9 回答