文章内容
2021/5/7 13:53:07,作 者: 黄兵
TypeError: '<=' not supported between instances of 'str' and 'int'
最近在Ubuntu部署服务的时候,运行一段时间报错,具体如下内容:
TypeError: '<=' not supported between instances of 'str' and 'int'
同时下面还给出错误内容:
ValueError: Timeout value connect was 5, but it must be an int, float or None.
出现问题的原因:
str数据类型不能和int类型进行比较,需要将str类型转换成int类型。
下面的提示说明值错误,这里的5应该是str类型的,需要int,float或者空值。
解决方案:
出错代码示例:
request = requests.get(self._request_availability_ip_list, timeout = self._init_get_ip_list_timeout)
这里timeout应该是int数据类型,传入的是str数据类型,需要转换:
request = requests.get(self._request_availability_ip_list, timeout=int(self._init_get_ip_list_timeout))
参考资料:
1、TypeError: '<=' not supported between instances of 'str' and 'int' [duplicate]
黄兵个人博客原创。
转载请注明出处:黄兵个人博客 - TypeError: '<=' not supported between instances of 'str' and 'int'
评论列表