<i id='fUQfn'><tr id='fUQfn'><dt id='fUQfn'><q id='fUQfn'><span id='fUQfn'><b id='fUQfn'><form id='fUQfn'><ins id='fUQfn'></ins><ul id='fUQfn'></ul><sub id='fUQfn'></sub></form><legend id='fUQfn'></legend><bdo id='fUQfn'><pre id='fUQfn'><center id='fUQfn'></center></pre></bdo></b><th id='fUQfn'></th></span></q></dt></tr></i><div id='fUQfn'><tfoot id='fUQfn'></tfoot><dl id='fUQfn'><fieldset id='fUQfn'></fieldset></dl></div>

    1. <legend id='fUQfn'><style id='fUQfn'><dir id='fUQfn'><q id='fUQfn'></q></dir></style></legend>
      <tfoot id='fUQfn'></tfoot>

        <small id='fUQfn'></small><noframes id='fUQfn'>

          <bdo id='fUQfn'></bdo><ul id='fUQfn'></ul>

        如何在Python中打开和读取输入文件并将其打印到输出文件?

        How can I open and read an input file and print it to an output file in Python?(如何在Python中打开和读取输入文件并将其打印到输出文件?)

        <small id='alR0G'></small><noframes id='alR0G'>

        1. <i id='alR0G'><tr id='alR0G'><dt id='alR0G'><q id='alR0G'><span id='alR0G'><b id='alR0G'><form id='alR0G'><ins id='alR0G'></ins><ul id='alR0G'></ul><sub id='alR0G'></sub></form><legend id='alR0G'></legend><bdo id='alR0G'><pre id='alR0G'><center id='alR0G'></center></pre></bdo></b><th id='alR0G'></th></span></q></dt></tr></i><div id='alR0G'><tfoot id='alR0G'></tfoot><dl id='alR0G'><fieldset id='alR0G'></fieldset></dl></div>

              <tbody id='alR0G'></tbody>

            <tfoot id='alR0G'></tfoot>
              <bdo id='alR0G'></bdo><ul id='alR0G'></ul>

              1. <legend id='alR0G'><style id='alR0G'><dir id='alR0G'><q id='alR0G'></q></dir></style></legend>
                  本文介绍了如何在Python中打开和读取输入文件并将其打印到输出文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  那么,我如何才能要求用户向我提供输入文件和输出文件呢? 我希望用户提供的输入文件中的内容打印到用户提供的输出文件中。在这种情况下,用户应输入此

                  Enter the input file name: copyFrom.txt
                  Enter the output file name: copyTo.txt
                  

                  输入文件内只有文本"hello world"

                  谢谢。请尽可能保持简单

                  推荐答案

                  如果您只想复制文件,Shutil的复制文件会隐式执行循环:

                  import os
                  from shutil import copyfile
                  
                  openfile = input('Enter the input file name:')
                  outputfile = input('Enter the output file name:')
                  
                  copyfile(openfile, outputfile)
                  

                  这篇帖子How do I copy a file in Python?了解更多详细信息

                  这篇关于如何在Python中打开和读取输入文件并将其打印到输出文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                  How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                  Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                  How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                  Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                  How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)
                  • <tfoot id='n6Qo8'></tfoot>

                      <legend id='n6Qo8'><style id='n6Qo8'><dir id='n6Qo8'><q id='n6Qo8'></q></dir></style></legend>

                    1. <small id='n6Qo8'></small><noframes id='n6Qo8'>

                        <tbody id='n6Qo8'></tbody>
                        <i id='n6Qo8'><tr id='n6Qo8'><dt id='n6Qo8'><q id='n6Qo8'><span id='n6Qo8'><b id='n6Qo8'><form id='n6Qo8'><ins id='n6Qo8'></ins><ul id='n6Qo8'></ul><sub id='n6Qo8'></sub></form><legend id='n6Qo8'></legend><bdo id='n6Qo8'><pre id='n6Qo8'><center id='n6Qo8'></center></pre></bdo></b><th id='n6Qo8'></th></span></q></dt></tr></i><div id='n6Qo8'><tfoot id='n6Qo8'></tfoot><dl id='n6Qo8'><fieldset id='n6Qo8'></fieldset></dl></div>

                            <bdo id='n6Qo8'></bdo><ul id='n6Qo8'></ul>