本文实例讲述了Python实现删除文件中含指定内容的行。分享给大家供大家参考,具体如下:
代码如下 | 复制代码 |
#!/bin/env python importshutil, sys, os darray=[ "Entering directory", "In function ", "Leaving directory", "__NR_SYSCALL_BASE", "arm-hisiv100-linux-ar ", "arm-hisiv100-linux-gcc ", "but argument is of type", "dereferencing type-punned pointer will break strict-aliasing rules", "differ in signedness", "does break strict-aliasing rules", "embedded '\0' in format", "excess elements in array initializer", "implicit declaration of", "make -C ", " rm -f", "this is the location of the previous definition", "warning: multi-line comment" ] defisInArray (array, line): foriteminarray: ifiteminline: returnTrue returnFalse if__name__=='__main__': argv=sys.argv argc=len(argv) ifargc<2: print"Usage: %s exit() fname=argv[1] fresult=fname+".result" withopen(fname,'r') as f: withopen(fresult,'w') as g: forlineinf.readlines(): ifnotisInArray(darray, line): g.write(line) |
米加小镇世界龙年无广告版 安卓版v1.81
米加小镇世界龙年无广告是一款模拟类手游,不少的玩家可能都玩过
部落冲突互通服 安卓版v17.100.1
部落冲突互通服是全球风靡的战争策略手游,连接安卓和iOS服务
我的世界恶魔模组资源包 (EDU HELL)最新版vDEATH
我的世界恶魔版是一款像素风格的开放世界沙盒游戏,游戏中你可以
艺术大亨天天拍卖变富翁 最新安卓版v1.31.0
艺术大亨天天拍卖变富翁是一款非常好玩的模拟经营类手游,在游戏
大型巴士司机游戏 安卓版v2.1.0
大型巴士司机是一款模拟驾驶类游戏,玩家们将在游戏中化身为大巴