将值从bash传输到python scrip

2024-04-24 09:38:23 发布

您现在位置:Python中文网/ 问答频道 /正文

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

#!/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

我想取一个值file并将其传输到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

我该怎么做?你知道吗

关于this answer注意,python脚本是在blender中启动的,而不是在bashshell中启动的


Tags: pygt脚本bashshiftbinpngscript
1条回答
网友
1楼 · 发布于 2024-04-24 09:38:23

blender.stackexchange

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

相关问题 更多 >