RF+Python 实战二: 常用方法

来源:互联网 发布:五知四会四个能力 编辑:程序博客网 时间:2024/05/21 10:55

自定义库里 ,定义函数 :outputInfoToFile

def outputInfoToFile(info, dir_or_file = None, mode = "w", is_record_time = "No"):
"""Output debug information to file"""
if not info:
return
this_moment = datetime.datetime.now()
format = "%Y-%m-%d %H:%M:%S"


full_path = getFullPath(name_or_path = dir_or_file, default_dir_name = "AutoTestLog", default_file_name = "detail.txt")
info = info + "\n"
if is_record_time.lower() == "no":
text = info
else:
text = this_moment.strftime(format) + " : " + info
with open(full_path, mode) as f:
f.write(text)

该函数可以应用到检测发送和返回数据的具体值 ,在固定路径下生成txt文件,查看想要获取的内容



原创粉丝点击