473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

any function to fill zeros to the right?? zfill??

if I want to fill zeros to the right, what function can help??
ex:
'1.23'=>'1.2300'
but '1.23'.zfill(6)=>'001.23'
Aug 14 '08 #1
2 6448
On Aug 13, 7:48*pm, Johnny <Ar*******@gmail.comwrote:
if I want to fill zeros to the right, what function can help??
ex:
'1.23'=>'1.2300'
but '1.23'.zfill(6)=>'001.23'
>>'1.23'.ljust(6, '0')
'1.2300'

Sebastian

Aug 14 '08 #2
Johnny wrote:
if I want to fill zeros to the right, what function can help??
ex:
'1.23'=>'1.2300'
but '1.23'.zfill(6)=>'001.23'
Use string formatting:
>>"%0.6f" % 1.5
'1.500000'

Christian

Aug 14 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stian | last post by:
Hi, I'm sort of new to Python and I've just discovered the amazing formatting using the % operator. One thing I can't figure out is how to format numbers so that they get leading zeros, for example...
4
by: KL | last post by:
I have the following function: void fillvaluecheck (int valuecheck, int size){ for (int m = 0; m < size; m++){ cout << valuecheck << endl; valuecheck = 0; cout << valuecheck << endl; }...
3
by: alex.mcshane | last post by:
Hi - I would be grateful for any advice on the following. Within DB2 for OS/390, the STRIP Scaler Function is available. Its function is, for example, to remove leading zeros from a string. ...
14
by: romayankin | last post by:
Hello All, I'm writing cross-platform code so i'm bound to standards. Here is the code I have: ~~~~~~~~~~~~~~~~~~ double **mx = new double*; for(int i = 0; i < col - 1; i++) { mx = new...
19
by: Robbie Hatley | last post by:
For your enjoyment, a function that expresses any integer with absolute value less-than-or-equal-to nine quintillion in any base from 2 to 36. (For larger bases, you could expand the "digit"...
1
by: williamvarah | last post by:
I want to be able to link a macro to an icon in excel so that I can run a function that I have in excel visual basic. I'm trying to use runcode to do this but it's not working. The code for the...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
2
by: Coll | last post by:
I have a query that has null values for some of the fields. I'd like those fields to display a zero instead of a blank so I can do totals on them (sum/totalling the field is not working with null...
0
by: Rominsky | last post by:
I am trying to use the fill command to draw a box around an object in an image. I can get the box drawn, but there seems to be a side effect. The fill command is adding white lines to the top and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.