如何用填充有测试用例的输入文件测试Python脚本? [英] How to test a Python script with an input file filled with testcases?

查看:96
本文介绍了如何用填充有测试用例的输入文件测试Python脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在参加在线裁判比赛,我想用一个充满测试用例的.in文件测试我的代码,以计时算法.如何获取脚本以从此.in文件中获取输入?

I'm participating in online judge contests and I want to test my code with a .in file full of testcases to time my algorithm. How can I get my script to take input from this .in file?

推荐答案

因此该脚本通常从stdin中获取测试用例,现在您要使用文件中的测试用例进行测试?

So the script normally takes test cases from stdin, and now you want to test using test cases from a file?

如果是这种情况,请在cmd行上使用<重定向操作:

If that is the case, use the < redirection operation on the cmd line:

my_script < testcases.in

这篇关于如何用填充有测试用例的输入文件测试Python脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆