Import::py

De wiki.nexiat.fr
Aller à la navigation Aller à la recherche
Fiche express
Domaine Python — modules
Mots-clés import, from

L'instruction import permet d'accéder aux fonctions fournies par des modules Python, standards ou personnels.

Importer un module

import math
import math as mathematiques

math.sqrt(16)
mathematiques.sqrt(16)

help("math")
help("math.sqrt")

Import partiel

Permet d'importer une seule méthode de la bibliothèque.

from math import fabs
fabs(-5)

from math import *

Importer ses propres modules

import monfichier
from nom_bibliotheque.objects import bouton

Voir aussi