我在正确读取 2 个文件时遇到了一些问题:
filetest1.txt 包含:
chocolate
coconut
banana
filetest2.txt 包含:
strawberry
orange
程序 :
proc callme {file1 file2} {
set file1 [open $file1 r]
set file2 [open $file2 r]
while {[gets $file1 line1] != -1} {
while {[gets $file2 line2] != -1} {
puts "inside : $line1"
}
puts "outside : $line1"
}
close $file1
close $file2
}
callme filetest1.txt filetest2.txt
输出显示:
inside : chocolate
inside : chocolate
outside : chocolate
outside : coconut
outside : banana
所以我的问题是为什么只有:
inside : chocolate
inside : chocolate
我预计会有:
inside : chocolate
inside : chocolate
outside : chocolate
inside : coconut
inside : coconut
outside : coconut
inside : banana
inside : banana
outside : banana
谢谢。