Get only numbers from string in python

后端 未结 8 1222
感动是毒
感动是毒 2020-12-06 18:37

I want to get only the numbers from a string. For example I have something like this

just=\'Standard Price:20000\'

And I only want it to pr

8条回答
  •  悲哀的现实
    2020-12-06 19:02

    you can use regex:

    import re
    just = 'Standard Price:20000'
    price = re.findall("\d+", just)[0]
    

    OR

    price = just.split(":")[1]
    

提交回复
热议问题