The following:
>>>import struct
>>>struct.unpack('!d', ('40d11998e5035288').decode('hex'))[0]
>>>
>>>17510.3889778429
I would like to be able to print the value 17510.3889778429 to a .csv output file. For some reason, when I write this to a file, it rounds the decimal and only writes:
17510.3889778
How would I print this with higher precision?
Thanks,
Ned
Assuming you’re using Python’s csv module, the documentation says that non-string data is formatted using
str(), and that seems to be where the truncation is happening. So one thing you could do is define your own class that stringizes the way you want:Yields: