python 给文件批量加‘“’ ”,"
2015-09-29 19:59
507 查看
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()
相关文章推荐
- Python面向对象之继承
- Python面向对象(一)
- python string 使用正则表达式 split()
- Python DeprecationWarning 类型错误
- 在Python中使用protobuf2.6.1 string format utf-8 and unicode error
- 用python + hadoop streaming 编写分布式程序的本地调试方法
- python 发邮件乱码
- Python 列表的清空
- python 数学前自动补0的方法
- python笔记集合
- python线程join的正解
- Python 迭代删除重复项,集合删除重复项
- python笔记-调用eval函数出现invalid syntax错误
- python list和tuple相互转化
- 关于Python学习之我见 不断更新
- python 使用全局变量 global
- Python-Open website
- Python中的对象赋值、浅拷贝与深拷贝
- Python Dict 词典的用法
- [转载]python encode和decode函数说明