本文主要是介绍TypeError: ‘<‘ not supported between instances of ‘NoneType‘ and ‘int‘,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
什么是TypeError
exception TypeError 1
Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the type mismatch. 当操作或函数应用于不适当类型的对象时引发。关联的值是一个字符串,提供有关类型不匹配的详细信息。
This exception may be raised by user code to indicate that an attempted operation on an object is not supported, and is not meant to be. If an object is meant to support a given operation but has not yet provided an implementation, NotImplementedError is the proper exception to raise. 用户代码可能会引发此异常,以指示不支持或不打算对对象执行尝试的操作。如果一个对象打算支持一个给定的操作,但还没有提供一个实现,那么将会引发NotImplementedError。
Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError. 传递错误类型的参数(例如,当需要int时传递列表)应导致TypeError,但传递错误值的参数(例如,超出预期边界的数字)应导致ValueError。
项目场景
# python代码
None < 1
问题描述
TypeError: '<' not supported between instances of 'NoneType' and 'int'
原因分析
None
和int
不能做大小比较,编程时候需要注意排除这种情况。
https://docs.python.org/3.7/library/exceptions.html#TypeError ↩︎
这篇关于TypeError: ‘<‘ not supported between instances of ‘NoneType‘ and ‘int‘的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!