Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove "leading" zeros from version number string?

How can I remove the "leading" zeros from following version number string?

5.002.008.80911 --> 5.2.8.80911

Thx.

like image 578
user3022917 Avatar asked Mar 06 '23 08:03

user3022917


1 Answers

Using str.split with str.join

Ex:

s = "5.002.008.80911"
print(".".join(str(int(i)) for i in s.split(".")))

Output:

5.2.8.80911
like image 126
Rakesh Avatar answered Mar 15 '23 18:03

Rakesh