Convert, or unformat, a string to variables (like format(), but in reverse) in Python

前端 未结 7 2371
[愿得一人]
[愿得一人] 2020-12-15 03:44

I have strings of the form Version 1.4.0\\n and Version 1.15.6\\n, and I\'d like a simple way of extracting the three numbers from them. I know I

7条回答
  •  不知归路
    2020-12-15 04:02

    >>> import re
    >>> re.findall('(\d+)\.(\d+)\.(\d+)', 'Version 1.15.6\n')
    [('1', '15', '6')]
    

提交回复
热议问题