问题描述
我试图重现这个例子 [https://github.com/bauyrjanj/NLP-TwitterData/blob/master/TwitterData%20-%20Problem%20Statement%20%26%20Data%20Collection.ipynb]使用带有 'tweepy' 的 twitter 数据,一切都会运行,直到这些代码行:
不知道怎么解决,
谢谢:)
tweets_data_path = 'tweets.txt'
tweets_data=[]
tweets_file_1 = open(tweets_data_path,'r')
# Read in tweets and store in list: tweets_data
for line in tweets_file_1:
tweet = json.loads(line)
tweets_data.append(tweet)
# Close connection to file
tweets_file_1.close()
# Print the keys of the first tweet dict
print(tweets_data[0].keys())
JSONDecodeError Traceback (most recent call last)
<ipython-input-50-e43cd5de029e> in <module>
4 # Read in tweets and store in list: tweets_data
5 for line in tweets_file_1:
----> 6 tweet = json.loads(line)
7 tweets_data.append(tweet)
8
/opt/anaconda3/lib/python3.8/json/__init__.py in loads(s,cls,object_hook,parse_float,parse_int,parse_constant,object_pairs_hook,**kw)
355 parse_int is None and parse_float is None and
356 parse_constant is None and object_pairs_hook is None and not kw):
--> 357 return _default_decoder.decode(s)
358 if cls is None:
359 cls = JSONDecoder
/opt/anaconda3/lib/python3.8/json/decoder.py in decode(self,s,_w)
335
336 """
--> 337 obj,end = self.raw_decode(s,idx=_w(s,0).end())
338 end = _w(s,end).end()
339 if end != len(s):
/opt/anaconda3/lib/python3.8/json/decoder.py in raw_decode(self,idx)
353 obj,end = self.scan_once(s,idx)
354 except stopiteration as err:
--> 355 raise JSONDecodeError("Expecting value",err.value) from None
356 return obj,end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)