Home > other >  Consult the python file operations
Consult the python file operations

Time:01-15

Ask the classmate of a Python file operation problem, demand is:

Increase the data file is a real-time dynamic, need real-time statistics in data increase file data lines, a great god please what method

CodePudding user response:

 n=0 
Pos=0
With the open (' z:/TMP. TXT) as f:
While True:
Time. Sleep (2)
F.s eek (pos)
N +=len (f.r eadlines ())
Print (n)
Pos=f.t ell ()
every 2 seconds to print a line number.
  • Related