Python中eval,exec这两个函数有着相似的输入参数类型和执行功能,因此在用法上经常出现混淆,以至经常用错,程序易抛出错误.下面主要通过这两个函数的语法来阐述区别,并用例子来进一步说明. 首先看下官方文档对这两个函数的说明: (1)eval(expr, globals=None, locals=None, /) Evaluate the given expr in the context of globals and locals. This call returns the expr…
<script language="javascript"> var user = '{name:"张三",age:23,'+ 'address:{city:"青岛",zip:"266071"},'+ 'email:"iteacher@haiersoft.com.cn",'+ 'showInfo:function(){'+ 'document.write("姓名:"+this…