我尝试运行这段代码,结果出错,问题出在什么地方?
intntl_appid = "9X8MBuUB**************MdYXbMMI"
intntl_appkey = "TwGi6************xEyXXe"
import leancloud
leancloud.init(intntl_appid, intntl_appkey)
TestObject = leancloud.Object.extend('TestObject')
test_object = TestObject()
test_object.set('greeting', "hello")
test_object.save()
错误信息如下,
JSONDecodeError Traceback (most recent call last)
File C:\ProgramData\miniconda3\envs\testenv\Lib\site-packages\requests\models.py:971, in Response.json(self, **kwargs)
970 try:
--> 971 return complexjson.loads(self.text, **kwargs)
972 except JSONDecodeError as e:
973 # Catch JSON-related errors and raise as requests.JSONDecodeError
974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
File C:\ProgramData\miniconda3\envs\testenv\Lib\json_init__.py:346, in loads(s, cls, objecthook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return defaultdecoder.decode(s)
347 if cls is None:
File C:\ProgramData\miniconda3\envs\testenv\Lib\json\decoder.py:337, in JSONDecoder.decode(self, s, _w)
333 """Return the Python representation of s
(a str
instance
334 containing a JSON document).
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
File C:\ProgramData\miniconda3\envs\testenv\Lib\json\decoder.py:355, in JSONDecoder.raw_decode(self, s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
JSONDecodeError Traceback (most recent call last)
Cell In[21], line 4
2 test_object = TestObject()
3 test_object.set('greeting', "hello")
----> 4 test_object.save()
File C:\ProgramData\miniconda3\envs\testenv\Lib\site-packages\leancloud\object_.py:243, in Object.save(self, where, fetch_when_save)
240 fetch_when_save = "true" if fetch_when_save else "false"
242 if self.is_new():
--> 243 response = client.post(
244 "/classes/{0}?fetchWhenSave={1}".format(
245 self.classname, fetch_when_save
246 ),
247 data,
248 )
249 else:
250 url = "/classes/{0}/{1}?fetchWhenSave={2}".format(
251 self.classname, self.id, fetch_when_save
252 )
File C:\ProgramData\miniconda3\envs\testenv\Lib\site-packages\leancloud\client.py:110, in need_init..new_func(*args, **kwargs)
107 if user:
108 headers["X-LC-Session"] = user.sessiontoken
--> 110 return func(headers=headers, *args, **kwargs)
File C:\ProgramData\miniconda3\envs\testenv\Lib\site-packages\leancloud\client.py:173, in check_error..new_func(*args, **kwargs)
170 if response.headers.get("Content-Type") == "text/html":
171 raise leancloud.LeanCloudError(-1, "Bad Request")
--> 173 content = response.json()
175 if "error" in content:
176 raise leancloud.LeanCloudError(
177 content.get("code", 1), content.get("error", "Unknown Error")
178 )
File C:\ProgramData\miniconda3\envs\testenv\Lib\site-packages\requests\models.py:975, in Response.json(self, **kwargs)
971 return complexjson.loads(self.text, **kwargs)
972 except JSONDecodeError as e:
973 # Catch JSON-related errors and raise as requests.JSONDecodeError
974 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
--> 975 raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
JSONDecodeError: Expecting value: line 1 column 1 (char 0)