python __doc__方法

__doc__方法是python的内置方法之一,该方法通常会输出指定对象中的注释部分。 NB(注意): # 后面的部分表示输出结果 代码如下:

class Debug: “”” This is a class for debugging “”” def __init__(self): “”” This funtion only has one property “”” self.x = 5 # debugmain = Debug()print(main.__doc__) # This is a class for debugging print(main.__init__.__doc__) # This funtion only has one property

我们可以看到,输出结果为注释中的内容。其中??print(main.__doc__)???输出的时??Debug???类中注释的内容,??print(main.__init__.__doc__)???输出的是??__init__(self)??函数中注释的内容。

爱情唯美短句子

python __doc__方法

相关文章:

你感兴趣的文章:

标签云: