Home > other >  About baidu faces API requests for help! urgent
About baidu faces API requests for help! urgent

Time:09-22

This is the wrong tip

Traceback (the most recent call last) :
The File "FACEID_TEST. Py", line 2, the in & lt; module>
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ site - packages/request/set py", line 2, the in & lt; module>
From the get import get
File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ site - packages/get/set py", line 3, the in & lt; module>
The from query_string import query_string
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ site - packages \ query_string \ set py", line 18, in & lt; module>
@ public. Add
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ site - packages \ public \ set py", line 65, in the add
Return _add (_caller_modules () [1], objects)
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ site - packages \ public \ set py", line 12, in _caller_modules
Frames.=inspect getouterframes (inspect currentframe ())
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ inspect py", line 1490, in getouterframes
Frameinfo=(frame) + getframeinfo (frame, the context)
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ inspect py", line 1464, in getframeinfo
Lines, lnum=findsource (frame)
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ inspect py", line 782, in findsource
Lines=linecache. Getlines (file, the module __dict__)
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ linecache py", line 47, in getlines
Return updatecache (filename, module_globals)
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ linecache py", line 137, in updatecache
Lines=fp. Readlines ()
The File "C: \ Users \ ASUS \ AppData \ Local \ designed \ Python \ Python37 \ lib \ codecs py", line 322, decode in
(result, consumed)=self. _buffer_decode (data, the self. Errors, final)
UnicodeDecodeError: 'utf-8' codec can 't decode byte 0 xb9 position in 127: invalid start byte


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
(the program exited with code: 1)




The code
# - * - coding: utf-8 - * -
The import request
The import urllib, sys
The import SSL
The import urllib. Request as urllib2


AK, # client_id for website access client_secret for website access of SK
The host='https://aip.baidubce.com/oauth/2.0/token? Grant_type=client_credentials & amp; Client_id=487344 d4eaa2429da0dde151f848c1e2 & amp; 43 cc8d26e9b64077b0a0f6bf2529c83b client_secret='
Request=urllib2. Request (the host)
Request. Add_header (' the content-type ', 'application/json; Charset=utf-8 ')
The response=urllib2. Urlopen (request)
The content=response. The read ()
If (content) :
Print (content)



I was written in python
  • Related