内置函数的使用:
1、eval()函数:对动态表达式进行求值。
x=2
str='x**2+2*x+9'
print(eval(str)) //将字符串生成语句执行。
17
2、exec()函数:执行动态语句;不返回值。
exec("for i in range(8):print(i,end=' ')")
0 1 2 3 4 5 6 7
3、compile()函数:编译代码为代码对象。
co=compile("for i in range(8):print(i,end=' ')",'','exec')
print(exec(co))
0 1 2 3 4 5 6 7 None