1

我可以列出要在保存字符串中插入变量名称的错误

例如

     dict set faultCode 1 "db connection failed \$dberr"
     dict set faultCode 2 "connection failed \$socketerr"

     set dberr "test"
     # should print "db conection failed test"

现在我想在字典中插入变量名或任何方式来做同样的事情。

4

1 回答 1

3

利用subst

dict set faultCode 1 "db connection failed \$dberr"
dict set faultCode 2 "connection failed \$socketerr"

set dberr "test"
puts [subst [dict get $faultCode 1]]
于 2013-09-12T14:51:25.900 回答