将值从bash传输到python脚本

将值从bash传输到python脚本,python,linux,bash,command-line,Python,Linux,Bash,Command Line,我在bash中有一个名为“”的脚本。它可以从系统文件夹执行,用于对选定文件进行自定义操作: #!/bin/bash while [ $# -gt 0 ]; do file=$1 #doing smf with selected file shift done Аlso,我知道在cmd中使用自定义python脚本启动Blender的能力: blender -b blendfile.blend -P script.py -x 1 -F PNG -f 1 我需要获取一个值

我在bash中有一个名为“”的脚本。它可以从系统文件夹执行,用于对选定文件进行自定义操作:

#!/bin/bash

while [ $# -gt 0 ]; do
    file=$1
    #doing smf with selected file
    shift
done
Аlso,我知道在cmd中使用自定义python脚本启动Blender的能力:

blender -b blendfile.blend -P script.py -x 1 -F PNG -f 1
我需要获取一个值
文件
并将其传输到python脚本中,以便在
script.py
中使用它:

#!/bin/bash

while [ $# -gt 0 ]; do
    file=$1
    blender -b blendfile.blend -P script.py//+put here $file// -x 1 -F PNG -f 1     
    shift
done
我该怎么做

关于:注意,python脚本在blender中启动,而不是在bash shell中启动

Blender会忽略
--
之后的所有参数,Python不会。您可以在Python中搜索
--
,并在使用

import sys
argv = sys.argv
argv = argv[argv.index("--") + 1:]  # get all args after "--"
您将要传递的参数如下所示

blender -b blendfile.blend -P script.py -x 1 -F PNG -f 1 -- $file

你是想说
blender-b blendfile.blend-P script.py“$1”-x 1-F PNG-F 1
在循环中不能满足你的要求吗?@tripleee来自Nils Werner works的回答。解释为什么这个简单的方法不起作用