Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1838798
  • 博文数量: 333
  • 博客积分: 10791
  • 博客等级: 上将
  • 技术积分: 4314
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-08 07:39
文章分类

全部博文(333)

文章存档

2015年(1)

2011年(116)

2010年(187)

2009年(25)

2008年(3)

2007年(1)

分类: Python/Ruby

2010-10-13 14:07:50

import os

#add expand
src_file = raw_input("source path: ")
expand = raw_input("expand: ")

#rename
bak_src = src_file + ".bak"
os.rename(src_file, bak_src)

input = open(bak_src)
#print input
output = open(src_file, 'w')

while True:
    line = input.readline()
    if line:
# print line;
        
        line = (line.strip()) + expand
# print line
        output.write(line)
        output.write("\n")
    else:
        break
output.close()
input.close()

print "OK"
 


阅读(1274) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~