标签: tcl
我已经编写了一个TCL脚本,但在制作字符串变量时我遇到了一个问题:
set a 100 set b "this is variable[$a]"
我想要b分配b =" this is variable[100]"但我得到了错误:
this is variable[100]
invalid command name 100
请帮我解决一下: - (。
答案 0 :(得分:2)
你只需要逃避它:
set a 100 set b "this is variable\[$a\]"
答案 1 :(得分:0)
其他可能性(但转出括号更好):
set b [format {this is variable[%d]} $a] set b [subst -nocom -noback {this is variable[$a]}]
文档: set, format, subst