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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:56:46+00:00 2026-06-15T03:56:46+00:00

first of all, sorry for this easy question. I know these questions are really

  • 0

first of all, sorry for this easy question. I know these questions are really basic. I need to save a txt file in Python 2.7 with several rows. I need to ask some suggestions to improve my basic code.

this is a basic example

file_out = open("..//example//test.text", "w")

for p in range(10):
    ID = str(p)
    A = p*10
    B = p+10
    C = p-10
    D = p+p
    E = p*2
    file_out.write("s% %s %s %s s% s%" % (ID,A,B,C,D,E)+ "\n")
file_out.close()

my question are:

  • i have this Error Message, and i did’n find a way to resolve

    Traceback (most recent call last):
    File "<interactive input>", line 1, in <module>
      ValueError: incomplete format
    
  • my element to save (ex: ID,A,B,C,D,E) are several (30 elements), and
    i use a long line of s%. IS there an elegant way and compact to code
    this line?.

  • i wish to save also an head (ex: ID,A,B,C,D,E). What is the best way
    to do this?

  • 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-15T03:56:47+00:00Added an answer on June 15, 2026 at 3:56 am

    you have a typo

    file_out.write("%s %s %s %s %s %s" % (ID,A,B,C,D,E)+ "\n")
    

    or

       file_out.write("%s %s %s %s %s %s\n" % (ID,A,B,C,D,E))
    

    or

    file_out.write(" ".join(["%s" %i for i in [A, B, C, D, E]]))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, first of all sorry about this question it must be pretty straight forward
First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried
First of all, I'm fairly new to Java, so sorry if this question is
First of I'm very sorry but this questions is not so so specific. All
First of all, sorry for my English. I need some help with this. Recently
First of all sorry for asking this question on SO as this does not
this is my first question on this page, so first of all sorry for
First of all, I am sorry that this is not a 'question that can
First of all, sorry if this is an obvious question, but I'm rather new
First of all, sorry if this question is a little vague and rambling! I'm

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.