python模拟sed在每行添加##
# cat tou.py #!/usr/bin/env python'''
edit by qhz
Email : world77@163.coom
This scrip to add "###" at every line for file
'''
def usage():
print '''
===============================================
This script to add "###" at every line for file
Use Example:
python script.py file
===============================================
'''
import sys
import os
if len(sys.argv) == 2:
if os.path.isfile(sys.argv):
with open(sys.argv) as f:
con=f.readlines()
for i in range(0,len(con)):
print '###'+con.strip('\n')
else:
print "==============================================="
print "Your input file name is not exit or not correct"
print "Please try again ,bye ..."
print "==============================================="
else:
usage()
exit()
#
页:
[1]