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

前端 未结 4 857
情歌与酒
情歌与酒 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:28

    Read from file(s) and/or stdin:

    import fileinput
    for line in fileinput.input():
        process(line)
    

提交回复
热议问题