So the eval () what's the use, in where, what is a working principle
CodePudding user response:
Eval is to put the string expressions into python statement execution,Eval (" 14 "+" 2 ") is the result of the 142 because are two strings together, rather than "14 + 2", so it is 142 instead of 16
Eval (" 2 * 7 "+" 2 ") is the result of the 144, is the same reason, so understanding: eval there are two strings, the addition of the string is connected, becomes a python implementation "2 * 72" this statement, so the result is 144,
Can print (" 2 * 7 "+" 2 "), the output of 2 * 72, and eval is merely to its execution
CodePudding user response:
By the way, to understand this in addition to the above said, and calculating priorities, in parentheses to perform first, so the strings up first,CodePudding user response:
With your ideas, the results should be?CodePudding user response:
"14" + "2" rather then "142", but that's just split the string, so the eval (" 14 "+" 2 ") is the eval (" 142 "), which is 142CodePudding user response:
Have priority, to merge the string operation again, it's all said