For Python 2.X:
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
For <= Python 3.3:
import imp
imp.reload(sys)
Attention:
- the default encoding in Python3 is UTF-8
- Python3 does’t have the function setdefaultencoding()
For >= Python 3.4:
import importlib
importlib.reload(sys)
the related URL:
Reloading module giving NameError: name ‘reload’ is not defined
NameError: name ‘reload’ is not defined