使用正则表达式去除斜杆(\)

使用正则表达式去除斜杆(\),代码如下,记得斜杆是有两个的哦

import re 
text = "hahah\h\h\h\h"
x = re.sub(r'\\',"",text) #使用re模块中的函数sub
print(text)
print(x) 

得到的最终结果

hahah\h\h\h\h
hahahhhhh

猜你喜欢

转载自blog.csdn.net/aec153/article/details/105177992
今日推荐