# Python报错：'>' not supported between instances of 'NoneType' and 'NoneType'

``````def cal_pm_iaqi(pm_val):
#计算PM2.5的IAQI
if 0 <= pm_val < 36:
iaqi = cal_linear(0, 50, 0, 35, pm_val)
elif 36 <= pm_val < 76:
iaqi = cal_linear(50, 100, 35, 75, pm_val)
elif 76 <= pm_val < 116:
iaqi = cal_linear(100, 150, 75, 115, pm_val)

def cal_co_iaqi(co_val):
#计算CO的IAQI
if 0 <= co_val < 3:
iaqi = cal_linear(0, 50, 0, 2, co_val)
elif 3 <= co_val < 5:
iaqi = cal_linear(50, 100, 2, 4, co_val)
elif 5 <= co_val < 15:
iaqi = cal_linear(100, 150, 4, 14, co_val)

def cal_aqi(param_list):
#AQI计算
pm_val = param_list[0]
co_val = param_list[1]

pm_iaqi = cal_pm_iaqi(pm_val)
co_iaqi = cal_co_iaqi(co_val)

iaqi_list = []
iaqi_list.append(pm_iaqi)
iaqi_list.append(co_iaqi)

aqi = max(iaqi_list)
return aqi

def main():
# 主函数
print('请输入以下信息，用空格分开')
input_str = (input('(1)PM2.5 (2)CO:'))
str_list = input_str.split(' ')
pm_val = int(str_list[0])
co_val = int(str_list[1])

param_list = []
param_list.append(pm_val)
param_list.append(co_val)

#调用AQI计算函数
aqi_val = cal_aqi(param_list)
print('空气质量指数为：{}'.format(aqi_val))

# 按间距中的绿色按钮以运行脚本。
if __name__ == '__main__':
main()

``````
• 写回答

#### 2条回答默认 最新

• A Python 萌新花花 2022-04-30 21:17
关注
``````
def cal_pm_iaqi(pm_val):
#计算PM2.5的IAQI
if 0 <= pm_val < 36:
iaqi = cal_linear(0, 50, 0, 35, pm_val)
elif 36 <= pm_val < 76:
iaqi = cal_linear(50, 100, 35, 75, pm_val)
elif 76 <= pm_val < 116:
iaqi = cal_linear(100, 150, 75, 115, pm_val)
return iaqi

def cal_co_iaqi(co_val):
#计算CO的IAQI
if 0 <= co_val < 3:
iaqi = cal_linear(0, 50, 0, 2, co_val)
elif 3 <= co_val < 5:
iaqi = cal_linear(50, 100, 2, 4, co_val)
elif 5 <= co_val < 15:
iaqi = cal_linear(100, 150, 4, 14, co_val)
return iaqi
``````
本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论 编辑记录

#### 问题事件

• 已结题 （查看结题原因） 4月30日
• 已采纳回答 4月30日
• 创建了问题 4月30日

#### 悬赏问题

• ¥15 docker 运行OPEN-webui异常
• ¥15 基于ruoyi后台的小程序是二次开发还是原生开发
• ¥15 麒麟系统如何删除光盘刻录痕迹
• ¥15 recipe通过gem协议传的是什么
• ¥15 TS2307: Cannot find module 'cc'.
• ¥15 100小时学会sap 书上pp章节5.22，标准成本计算逻辑？
• ¥50 达梦数据库误删日志文件重做DAMENG01.log启动仍然-712错误
• ¥15 cellranger化学处理类型报错
• ¥15 用texstudio插入图片出现下面情况，怎么办
• ¥15 ubantu 用samba挂载windows的共享文件夹，无法挂载二级目录和修改文件