我可以列出要在保存字符串中插入变量名称的错误
例如
dict set faultCode 1 "db connection failed \$dberr"
dict set faultCode 2 "connection failed \$socketerr"
set dberr "test"
# should print "db conection failed test"
现在我想在字典中插入变量名或任何方式来做同样的事情。
利用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]]