Python3 - reload() can not be called on __import__ object?

后端 未结 1 1120
迷失自我
迷失自我 2021-01-03 17:29

Ok so for a number of reasons, I\'ve been using s = __import__(\'parse\') for the longest time in Python2, now I sorta need to being my transitions to Python3 f

相关标签:
1条回答
  • 2021-01-03 18:27

    The reload built-in function has been moved to importlib module in Python 3.4:

    In [18]: from importlib import reload
    
    In [19]: reload?
    Reload the module and return it.
    
    The module must have been successfully imported before.
    

    As pointed out by @JPaget in comments reload() function has been moved from imp to importlib module in Python 3.4+. From what's new in Python 3.4:

    The reload() function has been moved from imp to importlib as part of the imp module deprecation

    0 讨论(0)
提交回复
热议问题