Python json.loads显示ValueError:Expecting,Delimiter:Line 1 [英] Python json.loads shows ValueError: Expecting , delimiter: line 1
本文介绍了Python json.loads显示ValueError:Expecting,Delimiter:Line 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试读取推文的json文件,但我一直收到此错误
I'm trying to read a json file of tweets but i keep getting this error
ValueError:Expecting,分隔符:第1行537列(字符536)
ValueError: Expecting , delimiter: line 1 column 537 (char 536)
Code:
import json
import pandas as pd
import matplotlib.pyplot as plt
import json
with open('/Users/Mustafa/desktop/tweets.json', 'r') as f:
line = f.readline() # read only the first tweet/line
tweet = json.loads(line) # load it as Python dict
print(json.dumps(tweet, indent=4)) # pretty-print
有什么主意我可以解决这个问题或我做错了什么吗?
any idea how I can fix this or what im doing wrong?
推荐答案
BAD json文件中没有定界符,它不是json!将分隔符放入文件中!!!
BAD json file without delimiter in it it`s not json! put the delimiter in file!!!
崇高的文字将向您显示行和行 cntr + p:linenumber:columnumber
sublime text will show you line and row cntr+p :linenumber:columnumber
这篇关于Python json.loads显示ValueError:Expecting,Delimiter:Line 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文