Use paiza's skill check to study python. Among them, I thought about a configuration to reproduce the standard input locally and test it, so make a note. Please point out any typos, more efficient ways, etc.
__ Added on December 30, 2016 __ __ There is no need to take such a method, and clarinet758 commented. Everything was OK with the following method. __
$ python ./answer.py < ./input.txt
Installation of python3. Introduction of pyperclip used for copying the clipboard Reference: Clipboard operation with python
.
├── answer.py #File for improving the production environment
├── conv.py #File for local conversion
├── input.txt #Input example file
└── proto.py #Main program description file
answer.py and input.py are empty at first, so the other two.
proto.py
#Creating a local execution environment
#Open file
inp = open("input.txt", mode="r")
#----Program from here----
#----Program so far----
#File close
inp.close()
conv.py
#Regular expression import
import re
#Module import copy to clipboard
import pyperclip
#Read file for conversion
with open("proto.py", mode="r") as prot, open("answer.py", mode="w") as answ:
#Loading the local environment
for line in prot:
#Replace keywords dedicated to local development environment with standard input
tmp = line.replace('inp = open("input.txt", mode="r")','')\
.replace('inp.readline()','input()')\
.replace('inp.close()','')
#Delete comment
tmp = re.sub(r'#.*','',tmp)
#Export other than blank lines
if tmp != '\n':
answ.write(tmp)
#Load the answer for clipboard copy
with open("answer.py", mode="r") as answ:
pyperclip.copy(answ.read())
First, copy and paste the standard input input example into input.txt as it is. Also, program from the comment of proto.py-Program from here. For standard input, get line by line with the following code.
proto.py
#For 1 row 1 data
date = inp.readline().rstrip() #rstrip removes rightmost blanks and line breaks
#For multiple data per line
date = inp.readline().rstrip().split(' ') #List by blank delimiter by split
Programming as usual. Type the following command in the terminal each time and search while checking the result.
python
$ python proto.py
After completion, delete the locally specific program and convert it to standard input with conv.py. Also copy to clipboard. All you have to do is paste it into the submission form.
python
$ python conv.py