Discuss / Python / TypeError里面居然不能直接格式化字符串?

TypeError里面居然不能直接格式化字符串?

Topic source

def product(numbers): if numbers is None: raise TypeError('numbers is None') if len(numbers) == 0: raise TypeError('numbers''s length is 0') s = 1 for n in numbers: if not isinstance(n, (int, float)): errormsg = '{0} is not a valid number'.format(n) raise TypeError(errormsg) s = s n return s


  • 1

Reply