python - 'list' 和 'int' 的实例之间不支持 '>='
问题描述
我正在尝试使用条件从 txt、文件的向量列表中进行 3 个切片,我已经尝试使用过滤器和列表推导来进行操作,但它们都给出了相同的错误。是什么导致了这个错误?
当我尝试运行它时,这会导致此错误:
Traceback (most recent call last):
File "teste5.py", line 25, in <module>
vetor_xB = vetor_x[vetor_x >= 400 : X <= 500]
TypeError:'>=' not supported between instances of 'list' and 'int'
解决方案
也许:
#Conditions
B = 0
G = 0
R = 0
for i in range(0,len(vetor_x):
if vetor_x[i]<=500:
vetor_xB[B] = vetor_x[i]
vetor_yB[B] = vetor_y[i]
B += 1
elif vetor_x[i]<=600:
vetor_xG[G] = vetor_x[i]
vetor_yG[G] = vetor_v[i]
G += 1
elif vetor_x[i] <= 700:
vetor_xR[R] = vetor_x[i]
vetor_yR[R] = vetor_y[i]
R += 1
推荐阅读
- azure-devops - 在 Azure 管道中动态创建变量
- flutter - 颤动:将小部件对齐/固定到行的底部
- angular - 为什么 Angular 内置指令不适用于单个组件?
- reactjs - 如何从“上传文件”组件中提取文件名并将它们显示在 UI 上的列表中?
- linux - Ubuntu - 我无法使用 sudo 启动应用程序和运行命令
- json - 仅保留具有字符串值的字段
- php - 浏览器重新启动时删除 Httponly Cookie
- c# - 有没有一种简单的方法可以摆脱这个 IF 循环?
- json - 解决这个简单的(?)JSONPath
- ios - muteLocalVideoStream 没有将agora中的视频静音