【发布时间】:2020-07-08 02:20:23
【问题描述】:
说明
我正在尝试让re.sub() 将所有撇号和逗号替换为空格。
代码
content = "he knew that the people were right. I'm I'm I'm I'm I'm"
content = re.sub("^[^*$<,>?!']*$", ' ', content)
OUTPUT:
"he knew that the people were right. I'm I'm I'm I'm I'm"
这会返回相同的字符串,并且不会将任何内容转换为空格。
我不确定我做错了什么。
【问题讨论】:
标签: python python-3.x regex