I'm trying to download a tarball by downloading the contents and then writing them to a file. This is basically how my code works:
from urllib import urlretrieve
contents = urlretrieve('http://example.com/file.tgz')
open('/tmp/my-tar.tgz', 'w').write(contents)
However, when I do that, I get an error (a TypeError
) that says 'expected a character buffer object' in the call to write
.
How would I write the contents of a tarball to a file?