我如何在 TCL 文件的字符串变量中添加括号 [英] How I add bracket in string variable in TCL file
本文介绍了我如何在 TCL 文件的字符串变量中添加括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经编写了一个 TCL 脚本,但是在创建字符串变量时遇到一个问题,如下所示:
设置一个 100set b "这是变量 [$a]"
我希望将 b 赋值为 b = "this is variable[100]
" 但出现错误:
请帮我解决它:-(.
解决方案
你只需要逃避它:
设置一个 100set b "这是变量\[$a\]"
I have written one TCL script but I have one problem when making a string variable as below:
set a 100
set b "this is variable[$a]"
I want b to be assign with b = "this is variable[100]
" but I got the error:
invalid command name 100
Please help me to fix it :-(.
解决方案
You just need to escape it:
set a 100
set b "this is variable\[$a\]"
这篇关于我如何在 TCL 文件的字符串变量中添加括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文