Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4256036
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:17:57+00:00 2026-05-21T05:17:57+00:00

I made a script to download a file, but it only works on Unix/Linux/OSX

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:17:57+00:00Added an answer on May 21, 2026 at 5:17 am

    From the Python 2 documentation:

    On Windows, ‘b’ appended to the mode
    opens the file in binary mode, so
    there are also modes like ‘rb’, ‘wb’,
    and ‘r+b’. Python on Windows makes a
    distinction between text and binary
    files; the end-of-line characters in
    text files are automatically altered
    slightly when data is read or written.
    This behind-the-scenes modification to
    file data is fine for ASCII text
    files, but it’ll corrupt binary data
    like that in JPEG or EXE files. Be
    very careful to use binary mode when
    reading and writing such files. On
    Unix, it doesn’t hurt to append a ‘b’
    to the mode, so you can use it
    platform-independently for all binary
    files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a script for IPN which works great but how can i immediately
I have made a script, but it's not working as expected, and I need
I create backups using the same .bak file. I've made a script to automagically
I made a shell script that get a remote file with ftp protocol, if
I made a Bash script to download this page http://php.net/downloads.php and then search for
I'm working on a script to download the images from mangareader, and I've been
I've made script which change information from different site, its occure when i click
I made a script that crawls through a domain, and I want it to
I made a script that spawns a remote shell or runs a local shell
i made a script that dynamically loads content into a div and whenever the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.