标签:reg 一个 seq gis led 输入 pytho isp print
from functools import singledispatch
import numbers
from collections import abc
from collections import Iterable
@singledispatch
def console(obj):
print("未知类型", obj)
@console.register(str)
def _(text):
print("文本", text)
@console.register(numbers.Integral)
def _(n):
print("数字", n)
@console.register(tuple)
@console.register(abc.MutableSequence)
def _(seq):
print("这是一个seq", seq)
@console.register(dict)
def _(dic):
print("这是一个字典", dic)
@console.register(Iterable)
def _(iters):
print("这是一个可迭代类型",iters)
if __name__ == ‘__main__‘:
console(1)
console(‘a‘)
console([1, 2, 3, 4, 5, 6])
console(range(8))
标签:reg 一个 seq gis led 输入 pytho isp print
原文地址:https://www.cnblogs.com/c-x-a/p/9576494.html