python - 尝试在 Python 中打开 JSON 文件时出现 JSONDecodeError
问题描述
我从Twitter 上抓取内容获得了以下 JSON 文件:
{"id": 911265668921733120,
"conversation_id": "911265668921733120",
"created_at": "2017-09-22 19:27:20 EAT",
"date": "2017-09-22",
"time": "19:27:20",
"timezone": "+0300",
"user_id": 61177265,
"username": "sircalic",
"name": "Dan",
"place": {"type": "Point",
"coordinates": [-1.18998912, 36.77644171]},
"tweet": "Bitcoin ain't stabilizing at $4,500 any time soon LOL but it's good to stock for long term.",
"language": "en",
"mentions": [],
"urls": [],
"photos": [],
"replies_count": 0,
"retweets_count": 0,
"likes_count": 0,
"hashtags": [],
"cashtags": [],
"link": "https://twitter.com/sircalic/status/911265668921733120",
"retweet": false,
"quote_url": "",
"video": 0,
"thumbnail": "",
"near": "Nairobi",
"geo": "",
"source": "",
"user_rt_id": "",
"user_rt": "",
"retweet_id": "",
"reply_to": [],
"retweet_date": "",
"translate": "",
"trans_src": "",
"trans_dest": ""
}
但是当我尝试使用以下代码在 Python 中打开它时:
current_file = str(os.getcwd()) + '/NewYork2017-09-30 00:00:00.json'
l = json.load(open(current_file))
我收到以下错误:
JSONDecodeError: Extra data: line 2 column 1 (char 1036)
我已经对该错误进行了一些研究,并且不断收到错误消息,即字符有问题,但我似乎找不到解决方案。
有什么可以解决的吗?
解决方案
推荐阅读
- ruby-on-rails - 写条件更好
- php - How to CONTAIN a PHP variable echoed content in a DIV
- php - 在 PHP 中连接到 MySQL 数据库
- java - 如何在 junit 测试中模拟 gradle 构建脚本?
- python - 在 Python 中使用多处理进行并行处理
- html - 在动态视频帖子上添加自动播放
- node.js - 带循环的递归调用 API
- linux - 无需使用 cli 从特定 IP 源下载 s3 文件
- bash - 源 /.bash_profile 命令不起作用
- python - 如何基于beautifulsoup修复我关于web scraper的python代码?