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 7885889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:11:05+00:00 2026-06-03T05:11:05+00:00

I made a Python script, that reads a text file then goes to a

  • 0

I made a Python script, that reads a text file then goes to a url, and adds the extension in the text file to the url. The problem is the script keeps stopping before it is done reading the file. I cant figure out why.

import urllib
f = open("extension/1.txt", 'r')

for x in f.readline():    
    a = f.readline()
    url = "http://www.link.com/whatever/%s" % a
    print url
    urllib.urlretrieve(url, a) 
  • 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-06-03T05:11:06+00:00Added an answer on June 3, 2026 at 5:11 am

    By calling for x in f.readline():, you’ll be going through the string that is the first line of the file as an iterable and then grabbing a new line for each character in the first line via a = f.readline(). I don’t think this is your intent.

    The file object f is iterable itself, so you can simply do the following:

    for line in f:
        value = line.rstrip('\n')
        url = "http://www.link.com/whatever/%s" % value
        print url
        urllib.urlretrieve(url, value)  # Not sure why you want to send value (your a) here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a c extension out of a python script that was fairly labour
I've made a quick python script that converts to Unicode from ASCII and back.
I have a python script that will take each file in a directory, iterate
I made a .pyw python script that I want to have running in the
My hosting provider says my python script must be made to be executable(chmod755). What
I'm building a fairly large enterprise application made in python that on its first
I've made myself a simple event system in python, and I found that the
While importing a python script from another script I want the script code that
I've made two versions of a script that submits a (https) web page form
I have a 4-dimensional dictionary I made with a Python script for a data

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.