← 返回题库
中级

实现设备黑名单管理

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    bl_csv = open_url(____).read()
    blacklist = pd.read_csv(StringIO(____))
    now = ____ + ____
    def is_blacklisted(____):
        active = blacklist[(____)&(____)]
        id_m = active[(____)&(____)]
        if not id_m.empty: return True, '____'+id_m.iloc[____]['____']
        if ip:
            ip_m = active[(____)&(____)]
            if not ip_m.empty: return True, '____'+ip_m.iloc[____]['____']
        return False, '____'
    print("____"+str(len(____))+"____")
    for val in list(____):
        ok, msg = is_blacklisted(str(____))
        print("____"+str(____)+"____"+msg)
    ok, msg = is_blacklisted(____)
    print(____)

示例

输入
solve()
期望输出
Blacklist (10 entries):
  SCR-0174: screen_blacklisted:key_theft
  SCR-0179: screen_blacklisted:repeated_failure
  SCR-0172: clear
  SCR-0180: screen_blacklisted:ddos_attack
  SCR-0179: screen_blacklisted:repeated_failure
  SCR-0001: clear
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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