six ---- Python2 and Python3 coding helper library
文章目录
metaclass
参考:
两种方法:
six.with_metaclass
1 2 3 4 5 6 7 8 9 10 11 12 13 14import six class MyMeta: def __new__(self, cls, name, bases, attrs): pass class MyBase: pass class MyClass(six.with_metaclass(MyMeta, MyBase)): pass接口说明
- six.with_metaclass(MetaClass, *otherBases)
six.add_metaclass
1 2 3 4 5 6 7 8 9 10 11 12 13 14import six class MyMeta: def __new__(self, cls, name, bases, attrs): pass class MyBase: pass @six.add_metaclass(MyMeta) class MyClass(myBase): pass
字符串类型 str
six.text_type
文章作者
上次更新 2022-03-07 (de34a70)