当我试图读取我用Stream下载并以txt格式保存的Twitter流数据时,出现“jsondecodererror:expectingvalue:line1column1(char0)”错误。在
尝试过对代码进行各种修改,就像在类似的问题中所暗示的那样,但都没有奏效。在
如果我从open中删除(errors='ignore'),就会得到以下错误UnicodeDecodeError
# String of path to file: tweets_data_path
tweets_data_path = 'Tweets.txt'
# Initialize empty list to store tweets: tweets_data
tweets_data = []
# Open connection to file
tweets_file = open(tweets_data_path, "r", errors='ignore')
# Read in tweets and store in list: tweets_data
for line in tweets_file:
if line.strip():
tweets_data.append(json.loads(line))
# Close connection to file
tweets_file.close()
当我在Jupyter笔记本中运行上面一行代码时,我遇到了“jsondecodererror:expectingvalue:line1column1(char0)”错误。在
目前没有回答
相关问题 更多 >
编程相关推荐