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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:39:42+00:00 2026-05-17T06:39:42+00:00

Using Python 2.6 I want to be able to convert numbers such as 00000,

  • 0

Using Python 2.6

I want to be able to convert numbers such as 00000, 000.00004 and 001 to strings. Such that each string is ‘00000’, ‘000.00004’ and ‘001’ respectively.

It is also necessary that the way to do this is the same with all numbers, and also copes when letters are fed into it. E.g. foo should become ‘foo’, 2bar should be become ‘2bar’ but 001 should still be ‘001’.

Using str([object]) the above numbers would go to ‘0’, ‘4e-05’ and ‘1’ respectively.

Any ideas?

EDIT:

@unholysampler (and everyone else) you are of course right.

I was simply getting confused because Sqlite3 was taking strings and then converting them to integers or floating point numbers when putting them into it’s database, despite it being declared as a string column. But this is another issue entirely.

SECOND EDIT:

If anybody was curious why Sqlite3 was doing that, it was because I had actually set the column to be of type ‘STRING’ in the schema, where it should have been type ‘TEXT’ (see http://www.sqlite.org/datatype3.html) – this was combined with Sqlite’s “dynamic typing” (see http://www.sqlite.org/faq.html#q3) and was enough to make me confused 🙂

Thank you for giving nice answers anyway 😀

  • 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-17T06:39:43+00:00Added an answer on May 17, 2026 at 6:39 am

    There is no number 0000 or 001. There is only 0 and 1. If you want to produce a string representation of a number, you can use string formatting to pad zeros.

    n = 1
    print '%03d' % n //001
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.