Python Func __Import__
# Python2.x Python __import__() Function
[ Python Built-in Functions](#)
* * *
## Description
The **__import__()** function is used to dynamically load classes and functions.
If a module changes frequently, you can use __import__() to dynamically load it.
## Syntax
__import__ syntax:
__import__ (name[, globals[, locals[, fromlist[, level]]]])
Parameter Explanation:
* name -- Module name
## Return Value
Returns a tuple list.
## Example
The following example demonstrates the usage of __import__:
## a.py file code:
#!/usr/bin/env python #encoding: utf-8 import os print('In a.py file %s' % id(os))
## test.py file code:
#!/usr/bin/env python #encoding: utf-8 import sys __import__ ('a')# Import the a.py module
Execute the test.py file, the output result is:
In a.py file 4394716136
[ Python Built-in Functions](#)
YouTip