当前位置: 移动技术网 > IT编程>脚本编程>Python > python访问类中docstring注释的实现方法

python访问类中docstring注释的实现方法

2018年06月22日  | 移动技术网IT编程  | 我要评论

本文实例讲述了python访问类中docstring注释的实现方法。分享给大家供大家参考。具体分析如下:

python的类注释是可以通过代码访问的,这样非常利于书写说明文档

class Foo:
  pass
class Bar:
  """Representation of a Bar"""
  pass
assert Foo.__doc__ == None
assert Bar.__doc__ == "Representation of a Bar"

希望本文所述对大家的Python程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网