我正在尝试使用exec()
在Python中动态执行一些代码语句>
从用户输入中接受代码语句。
我如何处理未关闭字符串引号时发生的EOF
异常?
例如
>> exec('if 5 > 1: print "5 is greater) # of course, this will raise an exception, # how do I handle this
如何使用
try-catch
处理此类情况?我应该在这里寻找什么exception
?
我试图使用exec()在Python中动态执行一些代码语句,该代码语句已从用户输入中接受。我如何处理当字符串用引号引起来的EOF异常...
EOFError是您要寻找的东西
[Hola buenas tardes mi problema es que me pide afuerza elcódigoalguien me puede ayudar