Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在考虑编写一些简单的静态代码分析,使用类声明和注释来生成 UML 图。
你能推荐一种以结构化方式解析 Python 脚本的舒适方法吗?我需要以__init__结构化的方式检测类声明、模块导入、参数分配和注释。
__init__
也许您可以指出我需要的特定部分?关于“Python 语言服务”(解析器、AST、...)有很大一部分,但我无法弄清楚我需要哪一个,我想避免深入研究所有这些。
您可以在加载代码后使用检查来检查代码:
http://docs.python.org/library/inspect.html