A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3schools.com/python/ref_func_exec.asp below:

Website Navigation


Python exec() Function

Python exec() Function

❮ Built-in Functions

Example

Execute a block of code:

x = 'name = "John"\nprint(name)'
exec(x)

Try it Yourself » Definition and Usage

The exec() function executes the specified Python code.

The exec() function accepts large blocks of code, unlike the eval() function which only accepts a single expression

Syntax

exec(object, globals, locals)

Parameter Values Parameter Description object A String, or a code object globals Optional. A dictionary containing global parameters locals Optional. A dictionary containing local parameters

❮ Built-in Functions

Track your progress - it's free!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4