python如何实现函数多态性

1243
2021/2/25 18:16:19
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

python如何实现函数多态性

在python实现函数的多态性,具体方法如下:

def remove_user(self,user_or_username):

try:

#If user_or_username is a User object

username = user_or_username.name

except AttributeError: #Oops -- didn't works. ask forgiveness ;-)

#If user_or_username is a string

username = user_or_username

remote.remove(username)

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: python连接sas的方法是什么