【发布时间】:2012-05-08 03:09:07
【问题描述】:
我对正则表达式非常陌生,并尝试使用 python 获取“\”字符
通常我可以像这样逃避“\”
print ("\\");
print ("i am \\nit");
输出
\
i am \nit
但是当我在 regX 中使用它时,它并没有像我想象的那样工作
print (re.findall(r'\\',"i am \\nit"));
并返回我的输出
['\\']
谁能解释一下原因
【问题讨论】:
-
在 python 中使用分号并不是一个好习惯。
-
与 [stackoverflow.com/questions/647769/… [1]: stackoverflow.com/questions/647769/… 相同的问题、问答