如何将打印函数追加并保存到excel或csv
代码:
firstpts= ['20']
for pfts in firstpts:
try:
(Operation)
print('test11 : PASSED')
except:
(Operation)
print('test11 : FAILED')
secondpts= ['120']
for sfts in secondpts:
try:
(Operation)
print('test22 : PASSED')
except:
(Operation)
print('test22 : FAILED')
如果我运行这个代码,我会在输出中得到这个
test11 : PASSED
test22 : FAILED
如何将所有try的输出重定向到csv
创建一个csv文件,并在其中写入信息
首先,你对try-catch的基本用法是错误的,因为如果elsing
不管怎样,抛开这一点不谈,您需要将所有记录的语句收集到一个字符串中,然后将该字符串写入一个“.csv”文件
就像this:- 你知道吗
相关问题 更多 >
编程相关推荐