← 返回题库
中级

实现素材格式合规验证

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    from pyodide.http import open_url
    from io import StringIO
    import pandas as pd
    crv_csv = open_url(____).read()
    creatives = pd.read_csv(StringIO(____))
    RULES = {'____':{'____':____,'____':____},'____':{'____':____,'____':____},'____':{'____':____,'____':____},'____':{'____':____,'____':____}}
    def validate(____):
        errs = []
        rules = RULES.get(____)
        if not rules: return ['____']
        if row['____']=='____' and float(____) > rules['____']:
            errs.append('____'+str(____)+'____')
        if float(____) > rules['____']:
            errs.append('____'+str(round(____))+'____')
        return errs
    ok = ____; fails = []
    for _, row in creatives.iterrows():
        errs = validate(____)
        if errs: fails.append(____)
        else: ok += ____
    print("____"+str(____)+"____"+str(len(____)))
    for f in fails[:____]:
        print("____"+f['____']+"____"+str(____))

示例

输入
solve()
期望输出
Creative validation: ok=110 fail=10
  FAIL CRV-0001: ['size_exceeded:51.4MB']
  FAIL CRV-0004: ['size_exceeded:5.1MB']
  FAIL CRV-0010: ['size_exceeded:5.5MB']
  FAIL CRV-0016: ['size_exceeded:5.1MB']
Python 代码 🔒 登录后使用
🔒

登录后即可练习

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