Top "String-formatting" questions

Commonly refers to a number of methods to display an arbitrary number of varied data types into a string.

Format numbers to strings in Python

I need to find out how to format numbers as strings. My code is here: return str(hours)+":"+str(minutes)+":"+…

python string-formatting
Python, print all floats to 2 decimal places in output

I need to output 4 different floats to two decimal places. This is what I have: print '%.2f' % var1,'kg =…

python floating-point string-formatting
How can I format a number into a string with leading zeros?

I have a number that I need to convert to a string. First I used this: Key = i.ToString(); But …

c# string string-formatting
How do I turn a python datetime into a string, with readable format date?

t = e['updated_parsed'] dt = datetime.datetime(t[0],t[1],t[2],t[3],t[4],t[5],t[6] print dt >>>2010-01…

python datetime string-formatting
Convert hex to binary

I have ABC123EFFF. I want to have 001010101111000001001000111110111111111111 (i.e. binary repr. with, say, 42 digits and leading zeroes). How?

python string binary hex string-formatting
Display a decimal in scientific notation

How can I display this: Decimal('40800000000.00000000000000') as '4.08E+10'? I've tried this: >>> '%E' % …

python string-formatting number-formatting scientific-notation
Format an Integer using Java String Format

I am wondering if it is possible, using the String.format method in Java, to give an integer preceding zeros? …

java string-formatting number-formatting
Format output string, right alignment

I am processing a text file containing coordinates x, y, z 1 128 1298039 123388 0 2 .... every line is delimited into 3 items using words = line.…

python alignment string-formatting
Output single character in C

When printing a single character in a C program, must I use "%1s" in the format string? Can I use …

c character string-formatting
Is it possible dynamically to add String to String.xml in Android?

Is it possible to have placeholders in string values in string.xml that can be assigned values at run time? …

android string string-formatting android-resources