attr/attrs模塊

attr簡介

開源庫,提供了爲函數或類提供更直接的建立屬性的方法。python

Github or PyPigit

用法

from attr import attrs, attrib


@attrs
class Foo:
    a = attrib(default=0)
    b = attrib(default='Hello world')

attrs簡介

與attr模塊相似,是最近比較流行的一款開源庫,不影響線程和協程。attrs.orggithub

用法

import attr


@attr.s
class Foo:
    x = attr.ib()
    y = attr.ib()
相關文章
相關標籤/搜索