立即学习:https://edu.csdn.net/course/play/24756/280710?utm_source=blogtoedu
1.Python原生字符串:
text=r"hello\nworld"
2.正则表达式转义字符:
text="apple price is $8, range price is $12"
result=re.findall("\$\d",text)
print(result)输出$8,$12
3.原生字符串与正则表达式:
正则表达式字符串解析规则:
(1)先把这个字符串放在Python语言层面进行解析
(2)把Python语言层面解析的结果再放到正则表达式层进行解析
text="\cba c"
result=re.match("\\\\c",text)
print(result.group())输出\c
或result=re.match(r"\\c",text)