read、readline()、readlines()

1、read

将整个文件读取成一个字符串

2、f

for line in f:

每次读取一行

3、readline

line = f.readline()
while line:
print(line.strip())
line = f.readline()

每次读取一行

4、readlines

for line in f.readlines():
print(line.strip())

每次读取一行

posted @ 2020-08-04 19:03  6+0  阅读(216)  评论(0编辑  收藏  举报