摘要: str_ = 'hello 【123 】 world 【456 】 nihao 789' print(re.sub("【.*】", '', str_)) (将【】之间的值消除) 此处sub是贪婪匹配,左括号不会匹配最近的右括号,而是最远处的右括号,导致world也被清除了 输出结果:hello ni 阅读全文
posted @ 2021-02-06 14:14 Brice_codes 阅读(73) 评论(0) 推荐(0)