fileinput: inplace
来源:互联网 发布:wifl网络电视机 编辑:程序博客网 时间:2024/06/01 09:36
if inplace is set as 1, then print will flush back the output to input file
def file_insert( fname, linenos = [], strings = [] ):
lineno = 0 # record the line no in the file
i = 0 # record the no. in linenos
for line in fileinput.input( fname, inplace = 1 ):
lineno += 1
line = line.strip() #for print add a "/n" to each line
# no finish each element in linenos
if i < len( linenos ) and linenos[i] == lineno:
# print "", for index not in strings
if i >= len( strings ):
print "/n", line
else:
print strings[i]
print line
i += 1
else:
print line
file_insert( "a.txt", [1,4,5], ["insert1", insert3"])
- fileinput: inplace
- FileInput/OutputStreamTest
- fileinput模块
- bootstrap-fileInput
- Bootstrap FileInput
- python fileinput
- Inplace Stable Partition 稳定划分
- Pandas drop_duplicates的inplace属性
- Exchange 2016- inplace hold, inplace archive, inplace ediscovery, litigation hold 都有啥区别以及原理
- [LeetCode] Inplace random shuffling an array
- java原地归并排序(inplace)
- (翻译)就地编辑器(Inplace Editor)
- python fileinput模块介绍
- python fileinput中的description
- Python fileinput 模块
- Python模块学习 ---- fileinput
- Python开发--fileinput
- bootstrap-fileinput图片上传
- OA-WorkFlow-FSM
- 辛卯兔年第一博
- VerifyError: Error #1107: ABC 数据已损坏,尝试的读取操作超出范围。
- iphone开发入门笔记
- xpath笔记
- fileinput: inplace
- 应用层捕获uevent事件
- js Replace结合正则 替换掉重复出现的字符串
- C#,ASP.NET jquery uploadify上传控件中文乱码解决办法
- FLEX4 SDK 下载 (含加载项、源代码)
- 改造struts2的控件
- GCC工具链
- 页面控制URL Rewrite
- JavaScript 创建类/对象的几种方式