[英]How to rewrite a python function/method without comments and docstrings?
在下面的 Python 方法中:
def some_method (params):
"""
Does an incredible thing.
"""
if(params):
# show current params
print(params)
有人怎么能使用 ast(抽象語法樹)刪除文檔字符串( "Does an incredible thing."
)和注釋( # show current params
)?
導致:
def some_method (params):
if(params):
print(params)
查看檢查文檔,那里有getmembers()
方法。 看來您可以使用__doc__
屬性提取方法文檔字符串。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.