pip install multipledispatch -i https://mirrors.aliyun.com/pypi/simple
from multipledispatch import dispatch class MyClass: ab = 11234 def __init__(self): self.aa = 1 @dispatch() def calculate(self): self.aa = 1111 @dispatch(int) def calculate(self, a): self._calculate(a) @classmethod def _calculate(cls, ip): print(cls.ab) print(ip) obj = MyClass() obj.calculate() obj.calculate(5) print(obj.aa)
不多废话,直接看代码就行了,不知道百度一下就行了。
标签:obj,calculate,C#,self,python,重载,def From: https://www.cnblogs.com/Pyxin/p/18185080