Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding

xiaoxiao2021-02-28  125

基于python3.6.1版本,在一个.py文件中,加入这3行: import requests, re, sys reload(sys) sys.setdefaultencoding("utf-8")

 

  出现这样的错误: sys.setdefaultencoding("utf-8") AttributeError: module 'sys' has no attribute 'setdefaultencoding'

 

原因分析: Python3字符串默认编码unicode, 所以sys.setdefaultencoding也不存在了

 

解决: 去掉,sys.setdefaultencoding

课程分享:

课程分享:Docker+Kubernetes(k8s)微服务容器化实践

课程分享:Kubernetes(k8s)生产级实践指南 从部署到核心应用

课程分享:(极客时间)深入剖析Kubernetes

转载请注明原文地址: https://www.6miu.com/read-25931.html

最新回复(0)