### I_Love_Div_4's blog

By I_Love_Div_4, history, 9 days ago,
        #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt" , "w" , stdout);
#endif


Is there anything in python like this. If python has something of this type can you guide me how to use it?

• -7

 » 9 days ago, # | ← Rev. 2 →   -17 .
•  » » 8 days ago, # ^ | ← Rev. 2 →   0 .
 » 9 days ago, # |   +8 check this blog
•  » » 8 days ago, # ^ |   0 I have seen this blog but this is not working
 » 8 days ago, # | ← Rev. 3 →   0 in python we don't have these lines its present only in Cpp see this link
 » 8 days ago, # |   0 import syssys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w')this works for me
•  » » 8 days ago, # ^ |   0 I think this is the intended way to do it in Python. Using this you can just use print() and input() as normal.Btw, if you want to go back to using stdin/stdout again, you can just do sys.stdin = sys.__stdin__ sys.stdout = sys.__stdout__