如何解决Anvil 错误:TypeError:'NoneType' 对象不可下标
TypeError: 'nonetype' 对象不可下标(键 'GCWR')
"""
This function gets the GCWR of the truck from the 'truck_specifications' data table
Parameters: brand,model,year,engine,drive,axle
Returns: gcwr
"""
def get_gcwr(brand,axle):
gcwr_row = app_tables.truck_specifications.get(Brand=brand,Model=model,Year=year,Engine_Type=engine,Drive_Type=drive,Axle_Ratio=axle)
gcwr = gcwr_row['GCWR']
return gcwr
一些细节:
- 变量“gcwr”应该根据上面显示的参数从数据表中的特定行返回一个数字
- 这以前有效,但是当我开始向表中添加更多数据时,它现在给了我如上所示的错误
- 我根据参数手动查看了数据表,有一行符合条件,应该返回值
- 数据表中列的数据类型为“数字”
"""
This function gets the truck specifications based on the users input
Parameters: none
Returns: value (allowable trailer GVWR)
"""
@anvil.server.callable
def get_truck_specifications():
# Get data from 'truck_inputs' data table
brand = get_brand()
model = get_model()
year = get_year()
engine = get_engine()
drive = get_drive()
axle = get_axle()
payload = int(get_payload())
passengers = int(get_passengers())
cargo = int(get_cargo())
hitch = int(get_hitch())
# Get data from 'truck_specifications' data table
gcwr = int(get_gcwr(brand,axle))
gvwr_truck = int(get_gvwr_truck(brand,axle))
base_weight = int(get_base_weight(gvwr_truck,payload))
gvw = base_weight + passengers + cargo + hitch
value = gcwr - gvw
return value
这是显示数据表示例的屏幕截图...
'Truck Specifications' data table image
解决方法
在我实现上传器后,数据表中的列似乎没有正确标记(相对于手动添加数据)。重新标注后,问题解决。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。