gpt4 book ai didi

string - TCL 字符串前置

转载 作者:行者123 更新时间:2023-12-04 06:10:55 25 4
gpt4 key购买 nike

只是一个简单但经常需要的操作 - 如何将字符串添加到变量:

set s "world!!!"
prepend s "Hello " #how to accomplish this effectively?
puts $s
#should print "Hello world!!!"

最佳答案

你可以编写一个过程prepend:

proc prepend {s_var txt} {
upvar 1 $s_var s
set s "${txt}${s}"
}

这正是您想要的。但我认为通常写起来更简单:

set s "Hello ${s}"

关于string - TCL 字符串前置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10009181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com