Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- @author: wagner
- Dynamic Module import in python
- """
- from __future__ import print_function #Compatibilidade func print python 2/3
- import importlib
- ModList = []
- for i in range(2):
- Mod = input('Informe o modulo %s a importar: ' %(i))
- ModList.append(Mod)
- ExitList = []
- for ModName in ModList:
- try:
- Imp = importlib.import_module(ModName)
- ExitList.append('Modulo "%s" importado com sucesso' %(ModName))
- except ImportError as ErrMsg:
- ExitList.append(' Erro ao importar modulo "%s": %s' %(ModName, ErrMsg))
- print('\n'*2, '\n'.join(ExitList))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement