启动“安全" eval() [英] Launching 'safe' eval()

查看:69
本文介绍了启动“安全" eval()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个irc机器人 https://github.com/mouuff/MouBot 我希望机器人在消息以!math开头时回复eval() 但是如果用户输入!math exit()之类的东西

I m making a irc bot https://github.com/mouuff/MouBot I would like the bot to reply the eval() when the message starts with !math but its creating failures if the user enter something like !math exit() and stuff like that

推荐答案

不要.

您似乎正在尝试创建数学解析器.然后使用数学解析器,而不是成熟的I-will-any-code-parser.如果使用* nix,则可以使用bc之类的程序来完成所需的操作.

It looks like you are trying to create a math parser. Then use a math parser, not a full-fledged I-will-run-any-code-parser. If you are using *nix, you could use a program like bc to do what you want.

这篇关于启动“安全" eval()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆