Python reads file scripts line by line and removes blank lines
There are many ways to read line by line, and here is a very simple one:
#! / usr/bin/python#-*-coding: utf-8-*-for line in open ("awip.conf"): print line
This line-by-line reading has a drawback, there are blank lines, and there will be no blank lines in the following code
#! / usr/bin/python#-*-coding: utf-8-*-def update_all_aw (): for line in open ("upmips.cfg"): a=line.strip () print (a) update_all_aw ()
For others, you can refer to the tutorial:
Three methods of reading file contents line by line by python
Python-- file reading