How to solve the abnormal running of python
This article mainly introduces "how to solve the abnormal operation of python". In the daily operation, I believe that many people have doubts about how to solve the problem of abnormal running of python. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to solve abnormal running of python". Next, please follow the editor to study!
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.4:
Import importlib importlib.reload (sys)
AttributeError: module 'sys' has no attribute' setdefaultencoding'
Based on the python3.6.1 version, in a .py file, add these three lines: import requests, re, sys reload (sys) sys.setdefaultencoding ("utf-8")
An error occurred: sys.setdefaultencoding ("utf-8") AttributeError: module 'sys' has no attribute' setdefaultencoding'
Cause analysis: the Python3 string is encoded by default unicode, so sys.setdefaultencoding no longer exists
Solution: get rid of sys.setdefaultencoding
At this point, the study on "how to solve the abnormal operation of python" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!