Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
exclude hyphen
#1
Hi,

I need some help with formatting.

I am exporting data in cvs file and need to exclude hyphen and add zero in front, for example "5-" should be exported as "05"

Any suggestion is appreciated, thanks!
Reply
#2
In [11]: s = '5-'

In [12]: '0{}'.format(s.strip('-'))
Out[12]: '05'
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Forum Jump:

User Panel Messages

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