0

Is it possible to write a number in scientific format into a json file without surrounding quotes?

I'm using json.dump to save the file.

Everything I've tried resulted in double quotes around the number.

number = 1234.5678
"{:e}".format(number) -> "1.234568e+03"
"%e" % number -> "1.234568e+03"
f"{d:.4e}" -> "1.2346e+03"

The desired output would be: 1.234568e+03

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Dezido
  • 3
  • 2
  • What you have shown *must* result in double quotes around the number because they are all ways to convert a number to a *string*. – mkrieger1 Jan 21 '22 at 16:04
  • Why does the JSON file have to contain the number in scientific notation, instead of any other notation? – mkrieger1 Jan 21 '22 at 16:05

0 Answers0