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

  • Home
  • SEARCH
  • 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 3622930
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:19:13+00:00 2026-05-18T23:19:13+00:00

Hey there, I’m pretty new to programming and I’ve got a problem with the

  • 0

Hey there, I’m pretty new to programming and I’ve got a problem with the Python Challenge; and I’ve removed the exact url in hopes avoiding any heavy spoilers.

Anyway, my problem is that I’m trying to open the file I’ve created, in WinRAR after I’ve ran the following code, and it tells me the file has an “unexpected of end of archive”. Naturally I’ve tried to rerun my code a few times just in case, and still no luck.

I’ve also grabbed the file with my browser from the same url to make sure that the file itself isn’t damaged, and opened it without any errors, so I’m pretty stumped. I guess I’m missing some basic element of the process?

I appreciate your help in advance!

import urllib

url = "http://www.pythonchallenge.com/pc/def/xxxxxxx.zip"
site = urllib.urlopen(url)

newfile = open(url.split('/')[-1],'w')    

newfile.write(site.read())

site.close()
newfile.close()
  • 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-18T23:19:14+00:00Added an answer on May 18, 2026 at 11:19 pm

    I’m guessing you’re on a Windows machine. (Mostly due to “WinRAR”)

    newfile = open(url.split('/')[-1],'w')
    

    The 'w' opens the file for writing, but in “text” mode. In text mode, some OSs (like Windows) convert '\n' to something else ('\r\n' in Window’s case.). To avoid this translation, open the file in binary mode 'b', with writing 'w': 'wb'

    These letters derive from fopen. See the manual page for fopen, as I feel it has a better description of the flags than the Python docs. (Note however, that Python adds a few things to the flags.)

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

Sidebar

Related Questions

Hey there I got a problem with my code, I compared three ways of
Hey there, I'm sort of new to Objective-C, and well, programming in general. I
Hey there, I'm a designer thats really new to programming with xcode or Objective-C
Hey there, I've got a block of HTML that I'm going to be using
Hey, in the Programming Pearls book, there is a source code for setting, clearing
Hey there guys and gals. I'm very new to php and am following various
Hey there, I'm new to mySQL, so my poor knowledge of the languages might
hey there i am having problem i have List<List<memoryCard>> that i want to show
Hey I was wondering if there were any way to upload images in ASP?
Hey, is there any built in functions or something like that in php that

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.