-1

I am editing a code line to pass the rate in quotes:

OO000OO00O0O0O000 ['rate']=O0O0OO00O000O0OOO #line:143

Somebody suggested me this solution:

OO000OO00O0O0O000 ['rate']="%.8f"%O0O0OO00O000O0OOO #line:143

I want to know what does "%.8f"% do exactly in python because when I googled it, I can not find anything about it. Please advise.

My question has to do with float number so it is different from the one that is already asked I believe.

Dave
  • 11
  • 1
  • 7

2 Answers2

1

This is a string formatter. "%.8f" means the argument is a floating point value to be displayed yo the 8th decimal. Then comes %O0... which is the argument. It is starting with the 'O' character so this is a variable containing the floating point value.

More about formatting here

Fabien Bouleau
  • 464
  • 3
  • 11
1

"%.8f" is a way to converts float to string according to a format. In this case the format will create 8 decimals in addition to the float. Try this:

"%.8f"%12345678 => "12345678.00000000"
"%.4f"%12345678 => "12345678.0000"
"%.2f"%12.34 = "12.34"

But I don't what the variable O0O0OO00O000O0OOO is. But that variable must be a float (or integer) to work with the format.

Mc_Topaz
  • 567
  • 1
  • 6
  • 21