這個是錯誤的提示
Traceback (most recent call last):
File "FACEID_TEST.py", line 2, in <module>
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\site-packages\request\__init__.py", line 2, in <module>
from get import GET
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\site-packages\get\__init__.py", line 3, in <module>
from query_string import query_string
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\site-packages\query_string\__init__.py", line 18, in <module>
@public.add
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\site-packages\public\__init__.py", line 65, in add
return _add(_caller_modules()[1], objects)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\site-packages\public\__init__.py", line 12, in _caller_modules
frames = inspect.getouterframes(inspect.currentframe())
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\inspect.py", line 1490, in getouterframes
frameinfo = (frame,) + getframeinfo(frame, context)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\inspect.py", line 1464, in getframeinfo
lines, lnum = findsource(frame)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\inspect.py", line 782, in findsource
lines = linecache.getlines(file, module.__dict__)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 47, in getlines
return updatecache(filename, module_globals)
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\linecache.py", line 137, in updatecache
lines = fp.readlines()
File "C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb9 in position 127: invalid start byte
------------------
(program exited with code: 1)
代碼
# -*- coding: utf-8 -*-
import request
import urllib, sys
import ssl
import urllib.request as urllib2
# client_id 為官網獲取的AK, client_secret 為官網獲取的SK
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=487344d4eaa2429da0dde151f848c1e2&client_secret=43cc8d26e9b64077b0a0f6bf2529c83b'
request = urllib2.Request(host)
request.add_header('Content-Type', 'application/json; charset=UTF-8')
response = urllib2.urlopen(request)
content = response.read()
if (content):
print(content)
我是用python寫的
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/57595.html
標籤:網絡協議與配置
上一篇:新手求救
