接口测试-将数据写入csv中

Posted lucky-sunshine

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了接口测试-将数据写入csv中相关的知识,希望对你有一定的参考价值。

将接口测试的返回值,写入到表格中

 

 

# 将testresult的数据写入csv中
# w为覆盖写,a为追加写

import csv

testresult = {"接口名称":"登录接口","测试结果":"测试通过"}
file = open("test2.csv","w")
for key,value,in testresult.items():
print(key,value)
file.write(str(key)+","+str(value)+" ")

file.close()

技术图片

 

 

 

testresult = {"接口名称":"登录接口","测试结果":"测试通过"}
file = open("test3.csv","w")
for key,value,in testresult.items():
print(key,value)
file.write(str(key)+","+str(value)+",")
file.write(" ")
file.close()

技术图片

以上是关于接口测试-将数据写入csv中的主要内容,如果未能解决你的问题,请参考以下文章