How I add bracket in string variable in TCL file

前端 未结 2 914
小鲜肉
小鲜肉 2021-01-29 02:15

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

2条回答
  •  梦谈多话
    2021-01-29 02:44

    Other possibilities (but escaping the brackets is better):

    set b [format {this is variable[%d]} $a]
    set b [subst -nocom -noback {this is variable[$a]}]
    

    Documentation: set, format, subst

提交回复
热议问题