python回车不能换行怎么办

python回车不能换行怎么办,第1张

python回车不能换行怎么办

python回车不能换行的解决办法:首先创建写入方法;然后将selenium的脚本运行结果写入【test_result.log】文件中;最后在写入参数str后加【\n】则会在每次完成写入后,自动换行到下一行。

python回车不能换行的解决办法:

现在需要一个写文件方法,将selenium的脚本运行结果写入test_result.log文件中

首先创建写入方法

def write_result(str):
    writeresult=file(r'D:\eclipse4.4.1 script\my_selenium\model\test_result.log','a+')
    str1=writeresult.write(str+'\n')
    writeresult.close()
    return str

如上str1=writeresult.write(str+'\n') 中写入的文件默认在一行显示,当调用此方法后,每次都会在该文件第一行写入

在写入参数str后加“\n”则会在每次完成写入后,自动换行到下一行,下次写入时便会在下一行写入

相免费学习推荐:python视频教程

以上就是python回车不能换行怎么办的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/682057.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-20
下一篇 2022-04-20

发表评论

登录后才能评论

评论列表(0条)

保存