search

Home  >  Q&A  >  body text

python - reload(sys)报Undefined variable: reload错误

author = 'jyang'
import sys
import json
reload(sys)
sys.setdefaultencoding('utf-8')
还报Undefined variable from import: setdefaultencoding错误

PHP中文网PHP中文网2803 days ago945

reply all(3)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:05:14

    What version of python?

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:05:14

    There is a possibility that python3 has been used
    reload has been placed in another location,

    from imp import reload
    

    But sys.setdefaultencoding('utf-8') is no longer meaningful,
    Because python3 uses unicode, there is no need to set utf-8 anymore

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:05:14

    from importlib import reload
    reload(modulename)

    reply
    0
  • Cancelreply