Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
splitting up long number
#4
If the number is a number, you could also try

time_stamp = 144345.20
string_time = str(time_stamp)    # Convert number to a string
hours = string_time[0:2]
minutes = string_time[3:5]
sec = string_time[4:]
print("{} hours {} minutes {} seconds".format(hours, minutes, sec))
resulting in:

Output:
14 hours 34 minutes 45.2 seconds
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
splitting up long number - by iFunKtion - Dec-07-2016, 02:17 PM
RE: splitting up long number - by stranac - Dec-07-2016, 02:24 PM
RE: splitting up long number - by iFunKtion - Dec-07-2016, 02:47 PM
RE: splitting up long number - by sparkz_alot - Dec-07-2016, 02:58 PM
RE: splitting up long number - by iFunKtion - Dec-07-2016, 03:09 PM
RE: splitting up long number - by sparkz_alot - Dec-07-2016, 03:33 PM
RE: splitting up long number - by snippsat - Dec-07-2016, 03:45 PM
RE: splitting up long number - by Larz60+ - Dec-07-2016, 05:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  float("{:.2f}" return long number? korenron 2 1,179 Jul-13-2022, 05:35 AM
Last Post: korenron
  Sequence Generator - Long number krux_rap 3 2,429 Aug-19-2020, 06:37 PM
Last Post: buran
  Factorial Code is not working when the given number is very long integer Raj_Kumar 2 2,410 Mar-31-2020, 06:40 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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