只要 destination 是字符串,就应运行文本处理器。请找出这次调用没有命中的原因。
Python
from functools import singledispatch
@singledispatch
def ship(payload, destination):
return f"default:{payload}:{destination}"
@ship.register(str)
def ship_text(payload, destination):
return f"text:{payload}:{destination}"
print(ship(100, "Paris"))