扫码关注官方订阅号
ringa_lee
a1 = re.compile('\{.*?\}' )
用Python 3.4验证过了
pythonimport re import sys s='{通配符}你好,今天开学了{通配符},你好' print("s", s) a1 = re.compile(r'\{.*?\}' ) d = a1.sub('',s) print("d",d) a1 = re.compile(r'\{[^}]*\}' ) d = a1.sub('',s) print("d",d)
python
import re import sys s='{通配符}你好,今天开学了{通配符},你好' print("s", s) a1 = re.compile(r'\{.*?\}' ) d = a1.sub('',s) print("d",d) a1 = re.compile(r'\{[^}]*\}' ) d = a1.sub('',s) print("d",d)
import re text = re.sub(r'{[^{}]*}', '', s) # 去除包含在……}中的内容
那么如果上面是[],方括号,怎样去除方括号和其中的内容
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
用Python 3.4验证过了
那么如果上面是[],方括号,怎样去除方括号和其中的内容