Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How to print zero-padded floating point numbers in python 2.6.1
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lorenzo Di Gregorio  
View profile  
 More options Nov 4, 7:04 pm
Newsgroups: comp.lang.python
From: Lorenzo Di Gregorio <lorenzo.digrego...@gmail.com>
Date: Wed, 4 Nov 2009 00:04:08 -0800 (PST)
Local: Wed, Nov 4 2009 7:04 pm
Subject: How to print zero-padded floating point numbers in python 2.6.1
Hello,

I thought that I could zero-pad a floating point number in 'print' by
inserting a zero after '%', but this does not work.

I get:

print '%2.2F' % 3.5
3.50
print '%02.2F' % 3.5
3.50

How can I get print (in a simple way) to print 03.50?

Best Regards,
Lorenzo


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lutz Horn  
View profile  
 More options Nov 4, 7:25 pm
Newsgroups: comp.lang.python
From: Lutz Horn <lutz.h...@fastmail.fm>
Date: Wed, 04 Nov 2009 09:25:53 +0100
Local: Wed, Nov 4 2009 7:25 pm
Subject: Re: How to print zero-padded floating point numbers in python 2.6.1
Lorenzo Di Gregorio schrieb:

> print '%2.2F' % 3.5
> 3.50
> print '%02.2F' % 3.5
> 3.50

> How can I get print (in a simple way) to print 03.50?

print '%05.2F' % 3.5

Lutz


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Rebert  
View profile  
 More options Nov 4, 7:37 pm
Newsgroups: comp.lang.python
From: Chris Rebert <c...@rebertia.com>
Date: Wed, 4 Nov 2009 00:37:52 -0800
Local: Wed, Nov 4 2009 7:37 pm
Subject: Re: How to print zero-padded floating point numbers in python 2.6.1
On Wed, Nov 4, 2009 at 12:04 AM, Lorenzo Di Gregorio

03.50

Cheers,
Chris
--
http://blog.rebertia.com


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google