在python中实现动态导入模块

test_fun.py:code

class TestPython(object):
    @classmethod
    def test_importlib(cls):
        return "importlib is good"

实现方式一: tt.py:class

from test_fun import TestPython
print TestPython.test_importlib()

动态实现方式二:test

import importlib
test_import = importlib.import_module("test_fun")
print test_import.TestPython.test_importlib()
相关文章
相关标签/搜索