Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Number Format
#2
Maybe. From the way buff is handled on line 4, it looks like a string. You could confirm this with print(type(buff)) after line 3, print(repr(buff)) might help too. You might be able to convert that string to a floating point number, and then use the format method of strings, or the even newer f-string syntax (Python 3.6+), to control the formatting output. That might lose some precision though. You would have to modify the string before converting to a float, because that's not a format the float function recognizes. float(buff.replace('EXP', 'E')) might work for that.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Changing Number Format - by moby - May-24-2019, 08:52 PM
RE: Changing Number Format - by ichabod801 - May-24-2019, 09:04 PM
RE: Changing Number Format - by moby - May-24-2019, 09:16 PM
RE: Changing Number Format - by ichabod801 - May-24-2019, 09:45 PM
RE: Changing Number Format - by snippsat - May-24-2019, 11:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,949 Jul-25-2022, 03:19 PM
Last Post: deanhystad
Photo How can I use 2 digits format for all the number? plumberpy 6 2,555 Aug-09-2021, 02:16 PM
Last Post: plumberpy
  multiple number format conversion oli_action 4 2,727 Aug-11-2020, 05:10 AM
Last Post: perfringo
  Number format william888 3 2,958 Aug-23-2019, 05:33 AM
Last Post: ThomasL
  changing format to Int Scott 3 2,596 Jun-19-2019, 06:33 AM
Last Post: ODIS
  changing { and } in str.format() Skaperen 10 5,279 May-16-2019, 05:07 AM
Last Post: Skaperen
  Counting the number of files related to particular format ambush 3 3,047 Nov-05-2018, 08:58 AM
Last Post: buran
  Date Format Changing Program Not Working pyth0nus3r 2 4,971 Jan-28-2017, 10:34 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020