手机
当前位置:查字典教程网 >脚本专栏 >python >Python linecache.getline()读取文件中特定一行的脚本
Python linecache.getline()读取文件中特定一行的脚本
摘要:比如:importlinecacheprintlinecache.getline('2.1_open.py',4)将返回我上一节事例代码文件...

比如:

Python linecache.getline()读取文件中特定一行的脚本1importlinecache

Python linecache.getline()读取文件中特定一行的脚本1printlinecache.getline('2.1_open.py',4)

将返回我上一节事例代码文件2.1_open.py的第4行文字,输出结果:

f = open('/home/evergreen/桌面/test')

查看linecache中的实现(我用的是Ulipad,所以直接将光标停留在linecache处,按F6键)

【Python linecache.getline()读取文件中特定一行的脚本】相关文章:

python备份文件的脚本

Python获取当前时间的方法

Python删除指定目录下过期文件的2个脚本分享

python逐行读取文件内容的三种方法

Python3基础之list列表实例解析

Python 条件判断的缩写方法

python 获取文件列表(或是目录例表)

Python tempfile模块学习笔记(临时文件)

python在linux中输出带颜色的文字的方法

python 查找文件夹下所有文件 实现代码

精品推荐
分类导航