为什么我们在此处将背斜线与星星一起使用,而不仅仅是以下代码中的星星?
为什么我们在这里将后斜线与一颗星星一起使用,而不仅仅是星星?
import re
text = 'The quick brown\nfox jumps*over the lazy dog.'
print(re.split('; |, |\*|\n',text))
```----> here in this line , and this code works well
Why did we use back slash with a star here instead of just a star??
import re
text = 'The quick brown\nfox jumps*over the lazy dog.'
print(re.split('; |, |\*|\n',text))
```----> here in this line , and this code works well
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Backslash可以让您逃脱特殊的角色,在这种情况下,您可以搜索
*
字符。在此处查看
re
的文档: https:// docss https:// docss .python.org/3/library/re.htmlThe backslash lets you escape special characters, in this case so that you can search for the
*
character.Check out the documentation for
re
here: https://docs.python.org/3/library/re.html