How to save fileobject/stream to text file on disk in python?
<p>I have a file object which is just a string with a large number of youtube urls taken from a playlist, how would I go about saving it to a .txt file?
Thanks</p>

<p>Assuming your file object is f:</p>

<pre><code>with open("urls.txt", "w") as urls_file:
    urls_file.write(f.read())
</code></pre>

<p>It may need improvement depending on the file size.</p>

python python-3.x