[問題] 寫檔問題
Hi,
各位好!想請教一個寫檔的問題。
我發現python寫檔好像是一次性把全部寫入。例如:
#!/usr/bin/env python
import time
of = open("output.dat", "w")
for i in range(0, 100):
time.sleep(1)
of.write("test\n")
of.close()
我用tail -f output.dat觀察有無文字出現,
感覺是要等到of.close()才會一次寫入。
請問有方法可以同部寫入嗎?
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.184.14
推
11/05 03:26, , 1F
11/05 03:26, 1F
→
11/05 08:45, , 2F
11/05 08:45, 2F
→
11/05 11:10, , 3F
11/05 11:10, 3F
→
11/06 15:50, , 4F
11/06 15:50, 4F
→
11/06 15:51, , 5F
11/06 15:51, 5F
→
11/06 15:51, , 6F
11/06 15:51, 6F