我需要只匹配到空格,不要匹配到换行符/n/t之类的,也就是不能直接用/s
3条回答 默认 最新
CQ.abc 2023-04-15 11:52关注import re text = "Hello World\nThis is a test string with spaces." pattern = r' ' matches = re.findall(pattern, text) print(matches)解决 无用评论 打赏 举报
import re
text = "Hello World\nThis is a test string with spaces."
pattern = r' '
matches = re.findall(pattern, text)
print(matches)