I have the text "languageType": "en"
, and I want to replace it with en
. How do I do it using replace? I've tried this so far so it's not working
lang = s.split(":")[0].replace("[\"']", "", -1).strip()
print(lang)
But I keep getting "en"
The replace method doesn't accept a regular expression, but rather a string. To replace with a regex use re.sub()
. See How to input a regex in string.replace?
I've made the same mistake before, myself.
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.