最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
关于python写入文件自动换行的问题
时间:2018-06-27 编辑:猪哥 来源:一聚教程网
现在需要一个写文件方法,将selenium的脚本运行结果写入test_result.log文件中
首先创建写入方法
def write_result(str): writeresult=file(r'D:eclipse4.4.1 scriptmy_seleniummodeltest_result.log','a+') str1=writeresult.write(str+'n') writeresult.close() return str
如上str1=writeresult.write(str+'n') 中写入的文件默认在一行显示,当调用此方法后,每次都会在该文件第一行写入
在写入参数str后加“n”则会在每次完成写入后,自动换行到下一行,下次写入时便会在下一行写入
-
上一个: 利用Python读取txt文档的方法讲解
-
下一个: PHP程序员学习使用Swoole的理由
相关文章
- Golang ProtoBuf的基本语法详解 10-20
- Python识别MySQL中的冗余索引解析 10-20
- Python+Pygame绘制小球代码展示 10-18
- Python中的数据精度问题介绍 10-18
- Python随机值生成的常用方法介绍 10-18
- python3解压缩.gz文件分析 09-27