compatible python3

This commit is contained in:
BreakWa11 2016-06-21 21:04:41 +08:00
parent 044e1539e9
commit 8031337d65
8 changed files with 68 additions and 51 deletions

22
importloader.py Normal file
View file

@ -0,0 +1,22 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
def load(name):
try:
obj = __import__(name)
return obj
except:
pass
try:
import importlib
obj = importlib.__import__(name)
return obj
except:
pass
def loads(namelist):
for name in namelist:
obj = load(name)
if obj is not None:
return obj