Home > Article > Backend Development > What does python's import mean?
What does python’s import mean?
__import__() function is used to dynamically load classes and functions.
If a module changes frequently, you can use __import__() to dynamically load it.
Recommended: [Python Tutorial]
Grammar
##__import__ Syntax:__import__(name[, globals[, locals[, fromlist[, level]]]])Parameter description: name -- module nameReturn valueReturns a list of tuples. ExampleThe following example shows the use of __import__: a.py File code:
#!/usr/bin/env python #encoding: utf-8 import os print ('在 a.py 文件中 %s' % id(os))test.py File code:
#!/usr/bin/env python #encoding: utf-8 import sys __import__('a') # 导入 a.py 模块Execute the test.py file, the output result is:
在 a.py 文件中 4394716136
The above is the detailed content of What does python's import mean?. For more information, please follow other related articles on the PHP Chinese website!