python exec骚操作
  • 板块P1597 语句解析
  • 楼主KAMITO
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/8/23 14:08
  • 上次更新2024/8/23 16:01:41
查看原帖
python exec骚操作
747671
KAMITO楼主2024/8/23 14:08

将pascal改成python代码存入字符串,并用exec直接执行字符串内代码

def solve():
    a=0;b=0;c=0
    s=list(input())
    t=[]
    for i in s:
        if i!=':':
            t.append(i)
    t.append('print(a,b,c)')
    s=''.join(t)
    exec(s)

    return

test=1
# test=int(input())
for _ in range(test):
    solve()
2024/8/23 14:08
加载中...