解码谷歌转换python

时间:2017-02-09 13:14:41

标签: python json

我想使用python json模块解码Google翻译json响应。要获得回复,我向此网址发送请求

  

https://translate.google.com/translate_a/single?client=t&sl=auto&tl=en&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&pc=1&source=btn&ssel=0&tsel=3&kc=6&tk=839074.688319&q=strangulation

作为回应我得到了这个

[[["strangulation","strangulation",,,0],[,,,"ˌstraNGgyəˈlāSHən"]],,"en",,,,0.99414062,,[["en"],,[0.99414062],["en"]],,,[["noun",[[["strangling","throttling","choking"],""]],"strangulation"]],[["noun",[["the action or state of strangling or being strangled.","m_en_us1294825.001","death due to strangulation"],["the condition in which circulation of blood to a part of the body (especially a hernia) is cut off by constriction.","m_en_us1294825.003","A second risk is strangulation of the hernia, which occurs when the protruding tissue swells and cuts off the blood supply to the loop of intestine within it."]],"strangulation"]],[[["A police spokesman said: ‘The death was due to \u003cb\u003estrangulation\u003c/b\u003e .’",,,,3,"m_en_us1294825.001"],["Infants who cannot yet lift their heads are especially at risk for suffocation and \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.001"],["A second risk is \u003cb\u003estrangulation\u003c/b\u003e of the hernia, which occurs when the protruding tissue swells and cuts off the blood supply to the loop of intestine within it.",,,,3,"m_en_us1294825.003"],["‘Such \u003cb\u003estrangulation\u003c/b\u003e can cause sufficient brain damage to kill somebody if the blood supply is stopped for a few minutes,’ he said.",,,,3,"m_en_us1294825.001"],["She also had asphyxia due to \u003cb\u003estrangulation\u003c/b\u003e ; the hyoid bone directly under the bruising was fractured.",,,,3,"m_en_us1294825.001"],["Prophylactic surgical treatment should be recommended in this situation to avoid a potential catastrophic \u003cb\u003estrangulation\u003c/b\u003e of bowel later.",,,,3,"m_en_us1294825.003"],["A post-mortem examination later found the cause of death was oxygen starvation of the brain due to \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.001"],["A pathologist said the cause of death was from \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.001"],["The cord complications seen in their study were thrombosis, cord prolapse, umbilical vessel rupture, true knot, and cord encirclement with \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.003"],["The batterer may also turn to physical violence - kicking, punching, grabbing, slapping or \u003cb\u003estrangulation\u003c/b\u003e , for example.",,,,3,"m_en_us1294825.001"],["If the cause of death had been \u003cb\u003estrangulation\u003c/b\u003e or a blow to the head, would you necessarily expect to find DNA evidence in the home?",,,,3,"m_en_us1294825.001"],["It is stated that the death of victim had been caused due to \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.001"],["They can cause \u003cb\u003estrangulation\u003c/b\u003e by catching on things.",,,,3,"m_en_us1294825.001"],["A post-mortem examination confirmed the cause of death as \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.001"],["Two cases with autopsies were excluded because nonmedical issues were being adjudicated in a workman's compensation case and a medical examiner's case with a diagnosis of \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.001"],["death due to \u003cb\u003estrangulation\u003c/b\u003e",,,,3,"m_en_gb0819230.001"],["Inguinal hernias in babies and children however do need surgery to prevent \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.003"],["The homicide charge laid in connection with the \u003cb\u003estrangulation\u003c/b\u003e death has been raised to first-degree murder.",,,,3,"m_en_us1294825.001"],["The cause of death was given as \u003cb\u003estrangulation\u003c/b\u003e by ligature.",,,,3,"m_en_us1294825.001"],["But he added that the same lack of findings meant he also could not rule out other possibilities, such as \u003cb\u003estrangulation\u003c/b\u003e , sexual assault or deliberate drowning.",,,,3,"m_en_us1294825.001"],["The cause of death was \u003cb\u003estrangulation\u003c/b\u003e although the pathologist could not rule out a smothering by a pillow.",,,,3,"m_en_us1294825.001"],["The conspiracy angle arose after Gandhi Hospital forensic doctors declared that the actress died due to \u003cb\u003estrangulation\u003c/b\u003e and rape.",,,,3,"m_en_us1294825.001"],["The majority of these deaths resulted from suffocation or \u003cb\u003estrangulation\u003c/b\u003e caused by entrapment of the child's head in various structures of the bed.",,,,3,"m_en_us1294825.001"],["Operations for complications such as \u003cb\u003estrangulation\u003c/b\u003e or perforation, should they occur, are relatively straightforward and have a high success rate.",,,,3,"m_en_us1294825.003"],["The reported cause of death was cardiorespiratory arrest caused by asphyxia as a result of \u003cb\u003estrangulation\u003c/b\u003e and aspiration of gastric contents.",,,,3,"m_en_us1294825.001"],["Three fourths of the deaths were caused by entrapment in the bed structure leading to suffocation or \u003cb\u003estrangulation\u003c/b\u003e .",,,,3,"m_en_us1294825.001"],["death due to \u003cb\u003estrangulation\u003c/b\u003e",,,,3,"m_en_us1294825.001"]]]]

当我尝试使用

加载此响应值时
json.loads(resp)

我收到此错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

如何解码此谷歌翻译响应。

0 个答案:

没有答案