Current location - Recipe Complete Network - Healthy recipes - Python exec() example on the novice tutorial, the last result is 34 and I can’t understand it. Please give me some advice.
Python exec() example on the novice tutorial, the last result is 34 and I can’t understand it. Please give me some advice.

exec(expr, {'x':1,'y':2}) This sentence is obvious: 31+2=33

exec(expr, {' x':1,'y':2}, {'y':3,'z':4}):

x is passed in 1, y is passed in first It is 2, and the second pass is 3, which covers the previous 2. So y is 3, and z is passed in 4.

But in expr, z is reassigned 30, so the result is 31+3=34