exclude hyphen - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: exclude hyphen (/thread-2121.html) |
exclude hyphen - baolevani - Feb-20-2017 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! RE: exclude hyphen - wavic - Feb-20-2017 In [11]: s = '5-' In [12]: '0{}'.format(s.strip('-')) Out[12]: '05' |