diff options
| author | zhang <zch921005@126.com> | 2022-03-25 00:11:34 +0800 |
|---|---|---|
| committer | zhang <zch921005@126.com> | 2022-03-25 00:11:34 +0800 |
| commit | 3ed1c5d0e4018fc70012a6209a859a059f7127b5 (patch) | |
| tree | 2ca318fb2e23daf2964189a751fb61b20aa7515a /oop/MethodTest.py | |
| parent | 6f68e1818229e0d2dad760062e6b5bb137b88f5b (diff) | |
更新脚本
Diffstat (limited to 'oop/MethodTest.py')
| -rw-r--r-- | oop/MethodTest.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/oop/MethodTest.py b/oop/MethodTest.py new file mode 100644 index 0000000..67fdf57 --- /dev/null +++ b/oop/MethodTest.py @@ -0,0 +1,42 @@ + +from datetime import datetime + +class Test: + alias = 'wudaokou nash' + + @staticmethod + def static_mode(language): + print(f'static method, {Test.alias} codes in {language}') + + @classmethod + def class_mode(cls, language): + print(f'class method, {cls.alias} codes in {language}') + + +class Repr: + + def __init__(self, name): + self.name = name + + def __repr__(self): + return f'{self.__class__.__module__}.{self.__class__.__qualname__}(name={self.name})' + + def __str__(self): + return f'{self.name}' + + +if __name__ == '__main__': + t = Test() + t.static_mode('chinese') + t.class_mode('english') + + r = Repr('zhang') + print(r) + print(repr(r)) + print(str(r)) + + now = datetime.now() + print(now.__str__()) + print(now.__repr__()) + + |
