|
|
вернуться в форумОбщий форумpython and reading from files I am learning python. When i see the example of problem 1000 and 1001, python reads from stdin. How can i read from input.txt without changing my program every time i send it in. e.g. pascal uses #ifdef online_judge to read from files Re: python and reading from files Послано ilalex 13 апр 2013 23:06 In linux I prefer to use this command: xclip -out | python problem.py It takes input from clipboard and send it to script. Re: python and reading from files I use Windows on my computer. When i define a function like def invoer(place): if place=='file': f = open('input.txt', 'r') regel=f.readline() print(sum(int(x) for x in regel.split(' '))) f.close() else: print(sum(int(x) for x in input().split(' '))) invoer('console') I can use a file. Is there a smarter way? |
|
|