把文件每行的tab键分隔符改成逗号分隔符
###################################### #把文件每行的tab键分隔符改成逗号分隔符 # ###################################### from smtplib import SMTP as smtp from time import sleep import linecache startLine = 1 endLine = 517 i=startLine #read file content try: ## fobj=open("renren_45w.txt.txt",'r') fok=open('163_ok.txt','a+') except IOError,e: print "open error",e try: while(i>=startLine and i<=endLine): try: line = linecache.getline("163.txt",i) if len(line.strip())>0: ## print line,'len:',len(line) line=line.replace("\t\n","\n").replace("\t",",") fok.write(line) i=i+1 except Exception,e: print e ## continue except Exception,e: print e fok.close() print('Down')
作者:代码示例
出处:http://codemo.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
您的支持是我前进的动力,请猛击: