我在tcl中有以下代码:
set string1 "do the firstthing"
set string2 "do the secondthing"
Run Code Online (Sandbox Code Playgroud)
如何组合两个字符串 "do the firstthing do the secondthing"
你可以append像这样使用:
% set string1 "do the firstthing"
% set string2 "do the secondthing"
% append string1 " " $string2
% puts $string1
do the firstthing do the secondthing
Run Code Online (Sandbox Code Playgroud)
你可以把它们放在另一个旁边......
% set string1 "do the firstthing"
% set string2 "do the secondthing"
% puts "$string1 $string2"
do the firstthing do the secondthing
Run Code Online (Sandbox Code Playgroud)
或者,如果您的字符串在列表中,您可以使用join并指定连接器...
% set listofstrings [list "do the firstthing" "do the secondthing"]
% puts [join $listofthings " "]
do the firstthing do the secondthing
Run Code Online (Sandbox Code Playgroud)
tcl中的字符串连接只是并置
set result "$string1$string2"
set result $string1$string
Run Code Online (Sandbox Code Playgroud)