zoukankan      html  css  js  c++  java
  • python的动态加载机制??

    if __name__ == '__main__':
        
        import sys
        from PyQt5.QtWidgets import QApplication
        app = QApplication(sys.argv)  
        
        
    #####################################################   
        
        print('main')
        import sys
        sys.path.append("../")
        
        module_name = "view"   #模块名  
        class_name = "HomeView" #类名     
        method = "show"          #方法名  
        module = __import__(module_name) # import module  
        print ("#module:",module  )
        print('dir', dir(module))
        cl = getattr(module,class_name)    
        print("#class:",cl  )
        
    
        
        obj = cl() # new class  
        print("#obj:",obj  ) 
        mtd = getattr(obj,method)  
        print("#method:",mtd  ) 
        mtd() # call def  
        
        
        
    #####################################################   
        sys.exit(app.exec_())
    

    需要在__init__.py文件中引出才行....囧

    今天未来得及看的:

    https://github.com/processone/grapherl

    http://toutiao.com/i6215417552374333953/?tt_from=mobile_qq&utm_campaign=client_share&app=news_article&utm_source=mobile_qq&iid=3160476964&utm_medium=toutiao_ios

  • 相关阅读:
    CSU 1122
    CSU 1256
    CSU 1240
    HDU 1874
    CSU 1004
    Problem F CodeForces 16E
    Problem E CodeForces 237C
    Problem C FZU 1901
    12-30
    2016-12-29
  • 原文地址:https://www.cnblogs.com/ribavnu/p/4956607.html
Copyright © 2011-2022 走看看