我写了一个TCL脚本,但做如下字符串变量时,我有一个问题,TCL文件添加支架:我如何在字符串变量中
set a 100
set b "this is variable[$a]"
我希望B与B =“this is variable[100]
被分配“但我得到了错误:
invalid command name 100
请帮我解决它:-(
我写了一个TCL脚本,但做如下字符串变量时,我有一个问题,TCL文件添加支架:我如何在字符串变量中
set a 100
set b "this is variable[$a]"
我希望B与B =“this is variable[100]
被分配“但我得到了错误:
invalid command name 100
请帮我解决它:-(
你只需要逃避它:
set a 100
set b "this is variable\[$a\]"
从技术上讲,我们只需要跳过左括号。 –
非常感谢。我的问题是我使用了与TCL相同的工具,但它不接受\ [和\]作为字符串“[]”。 –
参见(HTTP的[Tcl的12个语法规则]:// TCL .tk/man/tcl8.6/TclCmd/Tcl.htm),特别是规则#7 –