1.read()

read()每次读取整个文件,放到一个字符串变量中,返回类型是String.

2.readline()
readline() 每次返回一行,字符串变量。

3.readlines() 

readlines()列表形式返回全文,每行作为一个字符串作为列表元素。

代码示例:

python中read(),readline(),和readlines()

输出结果:

python中read(),readline(),和readlines()

python中read(),readline(),和readlines()

python中read(),readline(),和readlines()

详细参见下方链接:

https://blog.csdn.net/database_zbye/article/details/8635470

相关文章:

  • 2021-06-14
  • 2021-07-15
  • 2022-12-23
  • 2021-05-17
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2021-06-08
  • 2021-05-21
  • 2021-05-01
  • 2021-10-08
  • 2021-09-28
  • 2022-12-23
相关资源
相似解决方案