Python中NameError: name 'reload' is not defined

Solve: NameError: name 'reload' is not defined problem

 

For Python 2.X:

import sys 
reload(sys)
sys.setdefaultencoding(“utf-8”)

For <= Python 3.3:

import imp 
imp.reload(sys)

note:

1. Python 2 and Python 3 are very different, Python 3 wherein the system default is utf-8 encoded.

2. Therefore, the case for using Python 3, there is no need sys.setdefaultencoding ( "utf-8") code.

3. The most important thing is, Python sys library 3 which has no setdefaultencoding () function of .

For> = Python 3.4:

import importlib
importlib.reload(sys)

 

Guess you like

Origin blog.csdn.net/qq_27575895/article/details/88788702
Recommended