我正在尝试使用 tcl 脚本(通过 VMD)编写文件。当我在 tk/tcl 控制台上键入命令“dir”时,它会显示我正在尝试生成的文件名。但是当我尝试在该工作目录文件夹中手动打开该文件时,它甚至没有显示在其中。
这是一段代码。
set fp [open "input.txt" w+]
puts $fp "test"
close $fp
我正在尝试使用 tcl 脚本(通过 VMD)编写文件。当我在 tk/tcl 控制台上键入命令“dir”时,它会显示我正在尝试生成的文件名。但是当我尝试在该工作目录文件夹中手动打开该文件时,它甚至没有显示在其中。
这是一段代码。
set fp [open "input.txt" w+]
puts $fp "test"
close $fp
有时,Windows 可能对实际文件夹的情况非常棘手。
如果您也在脚本中执行此操作:
# This is quite an incantation!
exec {*}[auto_execok cmd] /c start "" [file nativename [file normalize .]]
然后它应该在实际的当前目录上打开一个资源管理器窗口。这将让您检查文件是否确实存在,以及您所在的位置是否是您期望的位置。
这应该与它所说的相匹配:
# Print the current working directory
puts [pwd]
# Print the names of text files in the current directory, with full names
puts [glob -directory [pwd] *.txt]
如果不是,那可能是你真正的问题……</p>