需求
s = 'http://utf8.api.smschinese.cn/?Uid=negopk&Key=xxxooo&smsMob=16666666666&smsText=驗證碼:8888'
替換字串s中的negopk
方法(python版)
pattern = re.compile('(?<=Uid=).*?(?=&)') ret = pattern.sub('python', s) # 將字串中匹配的部分替換為python print(ret)
結果
http://utf8.api.smschinese.cn/?Uid=python&Key=xxxooo&smsMob=16666666666&smsText=驗證碼:8888
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/204503.html
標籤:Python
上一篇:資料合并combing
