详谈python read readline readlines的区别
作者:jingxian 时间:2021-07-31 17:45:40
file 对象使用 open 函数来创建,下表列出了 file 对象常用函数read、readline、readlines区别:
1.从文件读取指定的字节数,size如果未给定或为负则读取所有。
file.read([size])
2.读取整行,包括 "\n" 字符。
file.readline([size])
3.读取所有行并返回列表,若给定sizeint>0,返回总和大约为sizeint字节的行, 实际读取值可能比 sizeint 较大, 因为需要填充缓冲区。
file.readlines([sizeint])
举个列子:
read
readline
readlines
如果大家想了解更多游戏活动与游戏攻略,请持续关注本站,本站小编将在第一时间为大家带来最好看、最好玩、最新鲜的游戏资讯。更多精彩内容,尽在jb51游戏频道!
来源:http://www.cnblogs.com/linuxliu/archive/2017/09/22/7573543.html
标签:python,read,readline,readlines
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python 数据化运营之KMeans聚类分析总结
2023-11-13 02:27:26
![](https://img.aspxhome.com/file/2023/4/97404_0s.png)
商业价值与用户价值的平衡
2008-12-10 18:42:00
![](https://img.aspxhome.com/file/UploadPic/200812/10/002_small-39s.jpg)
pytorch geometric的GNN、GCN的节点分类方式
2022-12-24 16:01:23
如何用Python一次性下载抖音上音乐
2022-10-31 04:14:09
![](https://img.aspxhome.com/file/2023/2/67412_0s.jpg)
网站数据库,是选SQL Server还是Access好
2008-05-23 13:19:00
Python如何使用qrcode生成指定内容的二维码并在GUI界面显示
2022-06-29 21:41:26
![](https://img.aspxhome.com/file/2023/2/133342_0s.png)
windows下wxPython开发环境安装与配置方法
2021-10-22 07:51:01
python爬虫 urllib模块发起post请求过程解析
2022-02-07 22:52:53
![](https://img.aspxhome.com/file/2023/8/69608_0s.png)
Python计时相关操作详解【time,datetime】
2023-08-24 17:12:56
python opencv圆、椭圆与任意多边形的绘制实例详解
2021-12-08 08:20:48
python+opencv实现论文插图局部放大并拼接效果
2023-12-07 17:29:12
![](https://img.aspxhome.com/file/2023/2/92442_0s.png)
python实现画出e指数函数的图像
2023-09-24 22:12:10
![](https://img.aspxhome.com/file/2023/4/79704_0s.jpg)
Python实现识别图片为文字的示例代码
2022-01-02 14:57:48
![](https://img.aspxhome.com/file/2023/8/112538_0s.png)
Python 3.10 中 6 个兴奋的新特性
2021-02-21 03:30:26
![](https://img.aspxhome.com/file/2023/1/127851_0s.jpg)
Python如何爬取qq音乐歌词到本地
2021-03-25 19:59:45
![](https://img.aspxhome.com/file/2023/8/97238_0s.jpg)
Appium+Python自动化测试之运行App程序示例
2023-07-29 01:54:20
![](https://img.aspxhome.com/file/2023/6/60986_0s.jpg)
python使用json.dumps输出中文问题
2023-11-17 22:04:46
![](https://img.aspxhome.com/file/2023/8/71428_0s.jpg)
python PyQt5/Pyside2 按钮右击菜单实例代码
2023-03-11 15:03:19
Python多线程、异步+多进程爬虫实现代码
2023-07-29 03:28:42
Django models文件模型变更错误解决
2021-05-14 11:02:10
![](https://img.aspxhome.com/file/2023/4/93864_0s.png)