我想使用 Python 文档字符串来更好地记录我的代码。
在下面的函数中,它将一个列表作为输入并将文件写入磁盘。我想知道如何将文档字符串中函数的输出记录为 None 中的函数返回类型。它有约定吗?
def foo(list_of_items: list) -> None :
"""Simple function.
Parameters
----------
list_of_items : list of str
list of some texts
Returns
-------
what is the best way to write this section?
"""
file = open('/path/output.txt')
file.write(list_of_items[1])
file.close()
Run Code Online (Sandbox Code Playgroud)