I have the text "level": NumberInt(3)
and I want to replace it with "level": 3
. How do I do it using replace? I've tried this so far so it's not working
o.level = str(s.replace(r'[^0-9]', ''))
print(o.level)
But I keep getting "level": NumberInt(3)
import re
s = '"level": NumberInt(3)'
re.sub(r'NumberInt\((\d+)\)', r'\1', s)
'"level": 3'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.