三重引号的正则表达式 [英] regex for triple quote
本文介绍了三重引号的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么正则表达式会在 Python 源代码中找到三引号(可能是多行)?
What regex will find the triple quote comments (possibly multi-line) in a Python source code?
推荐答案
Python 不是常规语言,无法使用正则表达式进行可靠解析.
Python is not a regular language and cannot reliably be parsed using regex.
如果您想要一个合适的 Python 解析器,请查看 ast 模块.您可能正在寻找 get_docstring
.
If you want a proper Python parser, look at the ast module. You may be looking for get_docstring
.
这篇关于三重引号的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文