Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the abnormal running of python

Shulou Source: shulou.com Published: 2022-06-01 07:29:13 09月13日 Update

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!

Tags: Utf-8 run learn more coding problem help practical big important next code function cause cause analysis character string that is case file Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Apple vpn Xiaomi Huawei