标签: python python-3.x
如何在Python中修复参数类型?
def truncus(fill=int): return [i for i in range(fill)]
答案 0 :(得分:2)
def truncus(fill): if type(fill) != int: raise Exception("A non-integer value was passed to truncus.") return [i for i in range(fill)]