THE WORLD'S LARGEST WEB DEVELOPER SITE

Python from Keyword

❮ Python Keywords


Example

Import only the time section from the datetime module, and print the time as if it was 15:00:

from datetime import time

x = time(hour=15)

print(x)
Run example »

Definition and Usage

The from keyword is used to import only a specified section from a module.


Related Pages

The import keyword.

The as keyword.

Read more about modules in our Python Modules Tutorial.


❮ Python Keywords