我用翻译器库翻译了200.000个文本数据,但是当我开始时,得到了这个追溯:
turkish =[]
for i in range(0,len(data)):
turkish.append(translator.translate(data.headline[i], src='tr').text)
我的DF: 标题类别 0上周德克萨斯州发生了两次大规模枪击事件……CRIME 1威尔·史密斯(Will Smith)加入Diplo和Nicky Jam参加2 ...娱乐 2休·格兰特(Hugh Grant)首次结婚,享年57岁 3 Jim Carrey炸弹“ Castrato” Adam Schiff和D ...娱乐 4朱莉安娜·玛格丽丝(Julianna Margulies)使用唐纳德·特朗普便便袋...娱乐
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-14-fdc2e4f79e89> in <module>()
9 pbarn = pbarn + 1
10 pbar.update(pbarn)
---> 11 turkish.append(translator.translate(data.headline[i], src='tr').text)
12 pbar.finish()
D:\Anaconda\lib\site-packages\googletrans\client.py in translate(self, text, dest, src)
170
171 origin = text
--> 172 data = self._translate(text, dest, src)
173
174 # this code will be updated when the format is changed.
D:\Anaconda\lib\site-packages\googletrans\client.py in _translate(self, text, dest, src)
79 r = self.session.get(url, params=params)
80
---> 81 data = utils.format_json(r.text)
82 return data
83
D:\Anaconda\lib\site-packages\googletrans\utils.py in format_json(original)
60 converted = json.loads(original)
61 except ValueError:
---> 62 converted = legacy_format_json(original)
63
64 return converted
D:\Anaconda\lib\site-packages\googletrans\utils.py in legacy_format_json(original)
52 text = text[:p] + states[j][1] + text[nxt:]
53
---> 54 converted = json.loads(text)
55 return converted
56
D:\Anaconda\lib\json\__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
352 parse_int is None and parse_float is None and
353 parse_constant is None and object_pairs_hook is None and not kw):
--> 354 return _default_decoder.decode(s)
355 if cls is None:
356 cls = JSONDecoder
D:\Anaconda\lib\json\decoder.py in decode(self, s, _w)
337
338 """
--> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()
341 if end != len(s):
D:\Anaconda\lib\json\decoder.py in raw_decode(self, s, idx)
355 obj, end = self.scan_once(s, idx)
356 except StopIteration as err:
--> 357 raise JSONDecodeError("Expecting value", s, err.value) from None
358 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)