猫史档案馆


【Python作品分享】exec:Python编译器(v1.0.1)

用户:PlumStevenPlumSteven查看:3 回复:2 评论:3 创建时间:2021-10-08T19:40:54


【作品展示】

center_image

 

【作品介绍】

会报错拉会报错啦

增加了报错功能!!!

 

【作品源代码】

code = ''

print('输入代码,运行输入start')
while True:
    line_program = input()
    if line_program == 'start':
        break
    code += line_program
print('程序开始运行')
try:
    exec(code)
except Exception as e:
    print('\033[1;31m', repr(e), '\033[0m')

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
lsk666666lsk666666

害,我这老双标了。看到写一大段代码解释python时想回复一句exec解决问题,看到exec又想说怎么没本事自己实现exec。总之,你还是比较鼓励自己手写解释器,最好是自创一个功能觉完善党语言,那天出了,我一定会顶,并且可能回用到项目里。这是个好想法,努力吧 imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"

点赞0


评论


Python-happyyyyPython-happyyyy

hhh

点赞0


评论