2024-09-30 14:23:46 发布
网友
我想删除任何后跟数字的“\”
s = "somecharacters\15othercharacters" s = re.sub(r"\\(\d+)", r"\1", s)
print(s)给了我othercharacters,而我期望的是somecharactersothercharacters
print(s)
othercharacters
somecharactersothercharacters
你能帮我修一下吗? 谢谢
我想你正在寻找这样的东西,正如你在问题的这一部分所要求的:
I want to remove any "\" followed by digits
import re s = r"somecharacters\15othercharacters" s = re.sub(r"\\\d+", '', s) print(s)
当运行此输出时:
我想你正在寻找这样的东西,正如你在问题的这一部分所要求的:
当运行此输出时:
相关问题 更多 >
编程相关推荐