考虑以下示例
a = "( False or False ) and not ( False and True and False ) and not ( False and True and False ) "
print eval(a)
b = "( False or False or False or False or False or False or True or False or False or False or False or False or False or False or False or False or False or False ) and not False and not False and not ( False and False ) and not ( False and False ) and not ( False and False ) and not ( False and False ) and not ( False and False ) and not ( False and False ) and not ( False and True ) and not ( False and False ) and not ( False and False ) and not ( False and False ) and not ( False and False ) and not ( False and False) and not False"
print eval(b)
第一个输出结果正确。但是对于第二个,尽管语法正确,却无法输出。
SyntaxError: EOL while scanning string literal
因为长度问题,我需要在程序中评估大型表达式。有什么建议吗?