Copying a stream in Python

前端 未结 1 2068
不知归路
不知归路 2020-12-18 17:44

How do I transfer the contents of a stream to another in Python?

The trivial solution would be

output.write(input.read())

but that

相关标签:
1条回答
  • 2020-12-18 18:32

    shutil.copyfile and shutil.copyfileobj for the rescue. See http://docs.python.org/library/shutil.html#module-shutil

    0 讨论(0)
提交回复
热议问题