python 给文件批量加‘“’ ”,"

file  = open('face.txt','r')
filew = open('face1.txt','w')    
try:
    for line in file:
        print(line)
        if line.strip() !='':
            line = '"'+line.strip()+'"'+",\n"    // 去掉空格、换行符 加上引号 逗号 换行符
            filew.write(line)
finally:
    file.close()
    filew.close()

 

posted @ 2015-09-29 19:59  lipeil  阅读(674)  评论(0编辑  收藏  举报