我正在尝试读取文件中的每一行,但是每次运行它都会出错:
set fr [open temp.txt r]
set a [read $fr]
set b [split $a '\n']
foreach i $b{
*code*
}
答案 0 :(得分:-2)
此代码可以正常工作:
set fr [open input_file.txt r]
set a [read $fr]
close $fr
set b [split $a \n]
set fa [open temp.txt a]
foreach i $b {
#Process items in list b
puts $fa $i
}
close $fa