WEEK8: Python Network Programming Socket Programming

  • Dynamic import module
    • The method of using the built-python import module __import__
      1  # Environment 
      2  # Dynamically importing modules .py 
      . 3  # lib 
      . 4  # --__ pycache__ 
      . 5  # --__init__.py 
      . 6  # --aa.py 
      . 7  
      . 8  # method 
      . 9 lib = __import__ ( " lib.aa " ) # explains uses internal 
      10 obj = lib.aa.C ()
       . 11  Print (obj.name)
       12 is  # method II 
      13 is  Import the importlib
       14 importlib.import_moudle ( " lib.aa " )
      15 print(aa.C().name)

       

Guess you like

Origin www.cnblogs.com/JYLCSS/p/11006249.html