Reimport a module in python while interactive

前端 未结 6 1293
后悔当初
后悔当初 2020-11-27 08:45

I know it can be done, but I never remember how.

How can you reimport a module in python? The scenario is as follows: I import a module interactively and tinker wit

6条回答
  •  离开以前
    2020-11-27 09:47

    If you want to import a specific function or class from a module, you can do this:

    import importlib
    import sys
    importlib.reload(sys.modules['my_module'])
    from my_module import my_function
    

提交回复
热议问题