Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Tcl脚本中的字符串格式_Linux_Tcl_Expect - Fatal编程技术网

Linux Tcl脚本中的字符串格式

Linux Tcl脚本中的字符串格式,linux,tcl,expect,Linux,Tcl,Expect,我在变量中有一个时间格式,如下所示: 时间12/12/12 我需要把它改成12-12-12。我如何在Tcl(Expect)脚本中实现它 我的脚本是test.tcl: #!/usr/bin/expect set time "12/12/12" # here I need something so time will become 12-12-12 puts $time # I will get 12-12-12 Tcl有一个内置的字符串函数: 字符串映射{/-}$time 您必须将其放在

我在变量中有一个时间格式,如下所示:

时间12/12/12

我需要把它改成12-12-12。我如何在Tcl(Expect)脚本中实现它

我的脚本是test.tcl:

#!/usr/bin/expect

set time "12/12/12"

# here I need something so time will become 12-12-12
puts $time 
# I will get 12-12-12 

Tcl有一个内置的字符串函数:

字符串映射{/-}$time

您必须将其放在
放置
之后,或放在新的
集合中

put[string map{/-}$time]

设置时间[string map{/-}$time]

Tcl有一个内置的字符串函数:

set time [clock format [clock scan $time] -format "%y-%m-%d"]
字符串映射{/-}$time

您必须将其放在
放置
之后,或放在新的
集合中

put[string map{/-}$time]
设置时间[字符串映射{/-}$time]

这对我来说很有用:
set time [clock format [clock scan $time] -format "%y-%m-%d"]
设置日期字符串[时钟格式[时钟秒]-格式“%y%m%d”-gmt true] 祝你好运

这对我很有用: 设置日期字符串[时钟格式[时钟秒]-格式“%y%m%d”-gmt true]
祝你好运

:在上面的语句之后打印$time时,它没有改变,给同样的东西:在上面的语句之后打印$time时,它没有改变,给同样的东西。我们已经忘记了Y2K的教训了吗?”这很可悲……12/12/12不是一个很好的例子。你是说年月日->年月日?我们已经忘记了Y2K的教训了吗这很可悲……12/12/12不是一个很好的例子。你是指年月日->年月日吗?