I made a script to download a file, but it only works on Unix/Linux/OSX when I’m downloading binary executables, swf’s, images, etc
\#Modfied section from PWB.py
import sys
if sys.version_info<(2,8):
import urllib as request
else:
import urllib.request as request
x=request.urlopen("http://homestarrunner.com/intro.swf")
y=x.read()
x.close()
z=open("intro.swf","w")
z.write(y)
z.close()
I will get the the file, and the usual unreadable garbage in the file, but it will be unreadable.
It seems binary files always have these sorts of problem on Windows.
Why is this?
PS. How could I write my python code so that it will download?
From the Python 2 documentation: