How to test a Python script with an input file filled with testcases?

前端 未结 4 868
情歌与酒
情歌与酒 2021-01-24 18:00

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 .i

4条回答
  •  无人共我
    2021-01-24 18:33

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

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

    my_script < testcases.in
    

提交回复
热议问题