file input and output

The following program can open a file and read the contents of the file line by line, it is worth mentioning that readline() reads line by line, while readlines() reads the entire file

f=open('G:\workspace\doc\name.txt','r')
line=f.readline()
while line:
print(line)
line=f.readline()
f.close()
 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324628546&siteId=291194637