我有一个循环并检查一个条件如下
while (t<len(var)):
PR=y
...
if z[t]<PR :
pass_check=1
else:
pass_check=0
t=t+1
#检查所有样品的z并打印结果
if pass_check==1:
print ('Test is pass')
elif pass_check==0:
print ('Test is fail')
else:
print ('Test is fail')
如何编写测试在文本文件中是通过还是失败,具体取决于条件,如果所有样本分别为1或0
答案 0 :(得分:1)
只需将其写入如下文件:
with open('your_file', 'w') as output_file:
output_file.write('Test is pass' if pass_check==1 else 'Test is fail')