0

I Have fetched timestamp from my log file but i need to remove millisecond and write it back to a new file.

i.e Ex:3:32:15.89567

I need to remove .89567 Finally i need is 3:32:15(hour,minute and second)

Can anyone help on this.

Madhu
  • 95
  • 1
  • 1
  • 6
  • Have you done any effort yet? – Psytho Sep 20 '16 at 08:18
  • 1
    Possible duplicate of [Python datetime to string without microsecond component](http://stackoverflow.com/questions/7999935/python-datetime-to-string-without-microsecond-component) – Julien Lopez Sep 20 '16 at 08:59

1 Answers1

0

Cut the string at the first '.' from the right with the rfind string method :

my_string  = '3:32:15.89567'
cut_string = my_string[ : my_string.rfind('.') ]
Bertrand Gazanion
  • 705
  • 1
  • 14
  • 19