更新时间:2024-10-28 13:59:23作者:欧曼老师
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
json
pass
except JSONDecodeError as e:
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
try:
return complexjson.loads(self.text, **kwargs)
except JSONDecodeError as e:
# Catch JSON-related errors and raise as requests.JSONDecodeError
# This aliases json.JSONDecodeError and simplejson.JSONDecodeError
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
loads
"""
if (cls is None and encoding is None and object_hook is None and
parse_int is None and parse_float is None and
parse_constant is None and object_pairs_hook is None
and not use_decimal and not kw):
return _default_decoder.decode(s)
if cls is None:
cls = JSONDecoder
if object_hook is not None:
kw['object_hook'] = object_hook
if object_pairs_hook is not None:
decode
instance containing a JSON document)
"""
if _PY3 and isinstance(s, bytes):
s = str(s, self.encoding)
obj, end = self.raw_decode(s)
end = _w(s, end).end()
if end != len(s):
raise JSONDecodeError("Extra data", s, end, len(s))
return obj
raw_decode
ord0 = ord(s[idx])
if ord0 == 0xfeff:
idx += 1
elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
idx += 3
return self.scan_once(s, idx=_w(s, idx).end())
__call__
def __call__(self, environ: dict, start_response: t.Callable) -> t.Any:
"""The WSGI server calls the Flask application object as the
WSGI application. This calls :meth:`wsgi_app`, which can be
wrapped to apply middleware.
"""
return self.wsgi_app(environ, start_response)
wsgi_app
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
raise
return response(environ, start_response)
finally:
wsgi_app
ctx = self.request_context(environ)
error: t.Optional[BaseException] = None
try:
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
full_dispatch_request
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
self,
rv: t.Union[ResponseReturnValue, HTTPException],
full_dispatch_request
self.try_trigger_before_first_request_functions()
try:
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
dispatch_request
getattr(rule, "provide_automatic_options", False)
and req.method == "OPTIONS"
):
return self.make_default_options_response()
# otherwise dispatch to the handler for that endpoint
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
def full_dispatch_request(self) -> Response:
"""Dispatches the request and on top of that performs request
pre and postprocessing as well as HTTP exception catching and
error handling.
translate
blocks = chunk_by_sentence(text, 5000)
else:
blocks.append(text)
result = []
for block in blocks:
res = baidu(block, frm, to)
result.append(res)
time.sleep(1)
return ''.join(result)
baidu
# "q": text,
# }
#print(params, headers, data)
#return
response = get_url(url, params, None, headers)
res = response.json()
#print(res)
result = []
if 'result' in res:
for item in res.get('result').get('trans_result'):
result.append(item.get('dst'))
json
try:
return complexjson.loads(self.text, **kwargs)
except JSONDecodeError as e:
# Catch JSON-related errors and raise as requests.JSONDecodeError
# This aliases json.JSONDecodeError and simplejson.JSONDecodeError
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
@property
def links(self):
"""Returns the parsed header links of the response, if any."""
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This is the Copy/Paste friendly version of the traceback.
The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.
The Federal University of Viçosa (UFV) is based in the state of Minas Gerais in Brazil. What began as a Higher College of Agriculture and Veterinary Science in 1922 is now a federal university – and has been since 1969 – based in the city of Viçosa. UFV is consistently ranked well when compared to other universities in Brazil.
This region is best known for its industrial development, and represents the most important economic region of Brazil offering plenty of opportunities for the universities tech graduates.
It is now a technical university which offers courses in engineering, agronomy, veterinary medicine, animal husbandry, and many other science related areas.
The university is spread across three separate campuses: Viçosa, Florestal and Rio Paranaíba. Each concentrates and offers specific courses, for instance Viçosa offers courses in a vast array of areas of the human knowledge while Rio Paranaíba offers specialised degrees such as vegetable production.
The UFV offers a wide range of services on each campus which includes laboratories, forest reserves, a library, sports and leisure areas, restaurants, banks, and medical services.
There are plenty of opportunities for exchange programmes, as the university has agreements in place with approximately 100 institutions from 24 different countries.
The UFV is also part of the Innovation Network created by the 100,000 Strong in the Americas initiative – a recent program designed to increase the number of U.S. students studying in the Western Hemisphere to 100,000, and the number of Western Hemisphere students studying in the United States to 100,000 by 2020.