← 返回题库
中级

实现灌溉超时告警

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    irr_csv = open_url(____).read()
    plans_csv = open_url(____).read()
    irr = pd.read_csv(StringIO(____))
    plans = pd.read_csv(StringIO(____))
    TIMEOUT_MULTIPLIER = ____
    now = ____ + ____
    def check_irrigation_timeout(____):
        plan = plans[plans['____']==irr_row['____']]
        if plan.empty: return False, None
        planned_dur = int(____) * ____
        timeout = planned_dur * TIMEOUT_MULTIPLIER
        ended = irr_row.get(____)
        if str(____) in (____):
            elapsed = now - float(____)
            if elapsed > timeout:
                return True, {'____':round(____),'____':round(____),'____':irr_row['____']}
        return False, None
    print(____)
    for _, row in irr.iterrows():
        timeout, info = check_irrigation_timeout(____)
        if timeout:
            print("____"+row['____']+"____"+str(____)+"____"+str(____)+"____")
        else:
            print("____"+row['____']+"____"+str(____))

示例

输入
solve()
期望输出
Irrigation timeout check:
  OK IRR001 status=completed
  OK IRR002 status=completed
  OK IRR003 status=aborted
  OK IRR004 status=completed
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码