python: strange behavior about exec statement
- by ifocus
exec statement:
exec code [ in globals[, locals]]
When I execute the following code in python, the result really confused me. Some of the variables were setup into the globals, some were setup into the locals.
s = """
# test var define
int_v1 = 1
list_v1 = [1, 2, 3]
dict_v1 = {1: 'hello', 2:'world', 3:'!'}
# test built-in function
list_v2 =…