Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python execfile() Function

Python execfile() Function

Python built-in function Python built-in function


Description

The execfile() function can be used to execute a file.

Syntax

The syntax of the execfile() method is as follows:


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

Parameters

Return Value

Returns the result of expression execution.


Example

The following examples show the use of the execfile function:

Suppose the file hello.py has the following content:


print('runoob');

execfile calls this file

execfile

(

'

hello.py

'

)

runoob

Python built-in function Python built-in function