天天看點

python中動态加載子產品和類方法實作

python中動态加載子產品和類方法實作測試代碼

檔案名: mytest.py 具體代碼如下:

注意:子產品名,類名,方法名都是變量。

執行後輸出如下:

> "d:\python27\python.exe"  "d:\test\src\mytest.py"

#module: <module 'mytest' from 'd:\test\src\mytest.py'>

#c: mytest.testclass

#obj: <mytest.testclass instance at 0x025f2aa8>

<mytest.testclass instance at 0x025f2aa8>

test

#mtd: <bound method testclass.echo of <mytest.testclass instance at 0x025f2aa8>>

#t: 3

1