Python Forum
extract version in a string - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: extract version in a string (/thread-21662.html)



extract version in a string - lokesh - Oct-09-2019

Hi,

I need help to extract only version in the following string.

str="psutil-5.4.5-cp27-none-win32.whl"

output should be : 5.4.5

Appreciate help on this.

Thx,
Lokesh


RE: extract version in a string - perfringo - Oct-09-2019

What have you tried?

Never use str as name or you will be unpleasantly surprised.


RE: extract version in a string - buran - Oct-09-2019

https://www.python.org/dev/peps/pep-0427/#file-name-convention