已有184人关注
AI圖像識別工具
发表在Python图书答疑 2019-07-16 《Python从入门到项目实践》第28章 AI图像识别工具
是否精华
版块置顶:

在執行imgr.py時,選擇要識別的圖片後,產生以下錯誤,應該如何修改

 self._output(request.encode('ascii'))

UnicodeEncodeError: 'ascii' codec can't encode characters



PS G:\Item\28AIpicture\imagerecognition> python imgr.py

Traceback (most recent call last):

  File "imgr.py", line 30, in <module>

    sys.setdefaultencoding( "utf-8" )

AttributeError: module 'sys' has no attribute 'setdefaultencoding'

PS G:\Item\28AIpicture\imagerecognition> python imgr.py

Traceback (most recent call last):

  File "imgr.py", line 184, in openfile

    self.typeTp()

  File "imgr.py", line 191, in typeTp

    self.get_bankcard(self.get_token())

  File "imgr.py", line 244, in get_token

    response = urllib.request.urlopen(request)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 222, in urlopen

    return opener.open(url, data, timeout)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 525, in open

    response = self._open(req, data)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 543, in _open

    '_open', req)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 503, in _call_chain

    result = func(*args)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 1360, in https_open

    context=self._context, check_hostname=self._check_hostname)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\urllib\request.py", line 1317, in do_open

    encode_chunked=req.has_header('Transfer-encoding'))

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1229, in request

    self._send_request(method, url, body, headers, encode_chunked)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1240, in _send_request

    self.putrequest(method, url, **skips)

  File "C:\Users\064105\AppData\Local\Continuum\anaconda3\lib\http\client.py", line 1107, in putrequest

    self._output(request.encode('ascii'))

UnicodeEncodeError: 'ascii' codec can't encode characters in position 61-65: ordinal not in range(128)


分享到:
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照