初级
解析屏幕支持的素材格式
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
st_csv = open_url("https://data.zuihe.com/dbd/ms-adlift/state_00/screen_types.csv").read()
screen_types = pd.read_csv(StringIO(st_csv))
def parse_formats(row):
fmts = [f.strip() for f in row['supported_formats'].split(',')]
return {'model':row['model'],'max_sec':int(row['max_video_sec']),'max_mb':float(row['max_file_mb']),'formats':fmts}
print("Format support:")
for _, row in screen_types.iterrows():
info = parse_formats(row)
print(" "+info['model']+": "+str(info['formats'])+" max="+str(info['max_sec'])+"s/"+str(info['max_mb'])+"MB")
def check(ftype, dur, size, row):
info = parse_formats(row)
errs = []
if ftype not in info['formats']: errs.append('unsupported')
if ftype=='MP4' and dur > info['max_sec']: errs.append('duration_exceeded')
if size > info['max_mb']: errs.append('size_exceeded')
return errs
row = screen_types.iloc[3]
for ftype, dur, sz in [('MP4',15,20.0),('MP4',20,25.0),('GIF',0,2.0)]:
errs = check(ftype, dur, sz, row)
print(" "+row['model']+" "+ftype+" dur="+str(dur)+"s size="+str(sz)+"MB: "+("OK" if not errs else str(errs)))
示例
输入
solve()
期望输出
Format support: LCD-1080P-H: ['MP4', 'JPG', 'PNG'] max=30s/50.0MB LCD-720P-H: ['MP4', 'JPG', 'PNG'] max=30s/30.0MB LCD-1080P-V: ['MP4', 'JPG', 'PNG', 'GIF'] max=30s/50.0MB LCD-720P-V: ['MP4', 'JPG'] max=15s/20.0MB LCD-720P-V MP4 dur=15s size=20.0MB: OK LCD-720P-V MP4 dur=20s size=25.0MB: ['duration_exceeded', 'size_exceeded'] LCD-720P-V GIF dur=0s size=2.0MB: ['unsupported']
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199