1. 首页
  2. 数据库
  3. 其它
  4. 47 – read、readline 和 readlines 方法的区别

47 – read、readline 和 readlines 方法的区别

上传者: 2020-12-23 00:34:09上传 PDF文件 27.02KB 热度 20次
1. 如何打开和读取文本文件内容 f = open('./files/readme.txt', 'r') print(type(f)) # print(f.read()) # f.close() 2. 使用 open函数打开文件,并返回一个 IO对象,该对象有3个用于读取文件的方法: read、readline 和 readlines。请使用代码描述这 3个方法的区别 # read: 读取文件的全部内容 print(f.read()) f.close() hello world I love you How are you? f = open('./files/readme.txt'
下载地址
用户评论