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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:35:45+00:00 2026-06-02T04:35:45+00:00

I want to have thousand separators in floats. What I’m doing is: >>> import

  • 0

I want to have thousand separators in floats. What I’m doing is:

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
'en_US.UTF-8'
>>> print '{0:n}'.format(123456.0)
123,456

When the integer part has 7 or more digits it does not work:

>>> print '{0:n}'.format(1234567.0)
1.23457e+06

The workaround that I found is to turn the float into an integer before formating:

>>> print '{0:n}'.format(int(1234567.0))
1,234,567

Is there a format string that would handle all floats without the need to turn it into an integer first?

  • 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-02T04:35:47+00:00Added an answer on June 2, 2026 at 4:35 am

    Use the locale modules format function:

    >>> locale.setlocale(locale.LC_ALL, 'English')
    >>> 'English_United States.1252'
    
    >>> print locale.format('%.2f', 123456789.0, True)
    >>> 123,456,789.00
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a number 12343423455.23353 . I want to format the number with thousand
I have strings which contains thousand separators, however no string-to-number function wants to consume
I have several hundred thousand endpoint URLs that I want to generate stats for.
We have a desktop application run on a few thousand client computers. We want
I have a to select a number between one to thousand... I dont want
First I want to say that, I have a vector which has thousand of
In a folder images I have a thousand xml files.Those filenames I want them
Current database have 200 thousand record. I want to make iPad application , can
Let's say I have thousands of users and I want to make the passwords
I have a JavaScript object with thousands of properties and what i want if

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.