zer0uno
zer0uno

Reputation: 8030

String formatting type codes

I'm reading about the string formatting type codes, but I can't get if there is any difference between%f and %F.

The book says for %f "floating point decimal" while for %F says "same as f, but uses uppercase letters". But which letters? because if I try:

>>> a = 3e-15
>>> '%F' % a
>>> '0.000000'

So I don't understand which letters it refers to.

Upvotes: 1

Views: 65

Answers (2)

Burhan Khalid
Burhan Khalid

Reputation: 174624

It means, quite literally, that it uses the capital letter F vs. the lowercase f. The upper case F was introduced in C99 and highlighted in inttypes.h and then borrowed from there in Python.

Upvotes: 1

Yuvika
Yuvika

Reputation: 6122

As per https://docs.python.org/2/library/stdtypes.html#string-formatting %F and %f are the same.

Upvotes: 1

Related Questions