在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()
相關文章
相關標籤/搜索