因此,我试图让 python 打印一个包含 tcl 变量的字符串,以及该变量的结果。我正在使用 nuke,以防对我的代码很重要。
[set THIS image]
Ln = "/Test/still/testing/$THIS\_clean_v001"
print(Ln) # this prints exactly the above
G = nuke.tcl('[puts "$THIS"] ')
print(G)
会返回图像这个词吗?
然后我可以把它分进去。问题是我输入那个 tcl 的文本字段在程序中很好地解决它,但是一旦我发送它来处理它就需要 $THIS
字面意思。
最佳答案
需要注意两点:
Tcl
puts
不返回值。听起来你想要 Tclset
, 确实如此。nuke.tcl
的文档位于 http://www.nukepedia.com/reference/Python表明:tcl(command, arg, arg, ...)
Run a tcl command. The arguments must be strings and passed to the command. If no arguments are given and the command has whitespace in it then it is instead interpreted as a tcl program (this is depreciated)
与其将其作为完整脚本调用,您似乎既可以使用未弃用的版本,又可以通过以下方式获得所需的行为:
G = nuke.tcl("set", "THIS")
应该返回 THIS
变量的值。
关于python - 嘿 python 解析 tcl 变量?核武器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16180880/