vi,gedit会在最后一行加上\n,实在找不到好的解决方法,只好自己写个shell script删掉
#!/usr/bin/env python
import sys
oldfile=sys.argv[1]
newfile=sys.argv[2]
print oldfile,newfile,
print
linecount = 0
str = ''
f = open(oldfile,'r')
for line in f:
linecount += 1
f = open(oldfile,'r')
for i,line in enumerate(f):
if (i==linecount-1):
str += line.replace('\n','')
# print line.replace('\n','')
else:
str += line
# print line,
#print len(str),str
f2 = open(newfile, 'w')
f2.write(str)
quit()