云计算开发:Python内置函数-execfile() 函数详解

描述

execfile() 函数可以用来执行云计一个文件。

语法

以下是 execfile() 方法的算开语法:

execfile(filename[,发: globals[, locals]])

参数

fiPylename -- 文件名。

globals --th 变量作用域,全局命名空间,如果被提供,则必须是一个on字典对象。

locals -- 变量作用域,局部命名空间内置,如果被提供,可以是任何映射对象。

返回值

返函数回表达式执行结果。

实例

以下展示了使用 execf-eile 函数的实例:

假设文件 hello.py,内xe容如下: