Python version of freopen()

后端 未结 5 1529
借酒劲吻你
借酒劲吻你 2020-12-29 10:58

Is there anything in python that can replicate the functionality of freopen() in C or C++? To be precise, I want to replicate the functionality of:

freopen(\         


        
5条回答
  •  粉色の甜心
    2020-12-29 11:34

    Try this:

    import sys
    sys.stdin = open('input.txt', 'r') 
    sys.stdout = open('output.txt', 'w')
    

    Text files are self explanatory. You can now run this code on Sublime Text or any other text editor.

提交回复
热议问题