簡體   English   中英

如何在沒有注釋和文檔字符串的情況下重寫 python 函數/方法?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM