小编tig*_*rae的帖子

如何使用reStructuredText创建新行?

如何在第一个强制换行/换行?我不希望它是一个新段落(即行之间没有额外的空格),我只想让文本从一个新行开始.谢谢!

markup restructuredtext line-breaks

12
推荐指数
3
解决办法
8577
查看次数

如何使用ast列出函数的参数?

我正在使用ast模块来解析Python模块中的文档字符串,以将我们的文档转换为docs格式.我正在使用以下内容将函数名称和文档字符串放入我的其余代码可以很好地使用的dicts列表中.我正在寻找能够获得函数参数的东西:

good_file = (file for file in os.listdir() if file[-3:] == '.py' and file != '__init__.py')

functions = []

for file in good_file:
     with open(file, 'r') as f:
         module = ast.parse(f.read())

     for node in module.body:
         if isinstance(node, ast.FunctionDef):
         entry = {"docs": ast.get_docstring(node), "fn_name": node.name, "params": ???}

         functions.append(entry)
Run Code Online (Sandbox Code Playgroud)

我正在寻找可以用来将函数的参数填入dict的东西.谢谢!

python abstract-syntax-tree

0
推荐指数
1
解决办法
977
查看次数