http://www.pr2hub.com/files/server_status_2.txt
有 JSON 文件。我想将它们分成每个类别(“server_id”、“server_name”等)
我已经尝试了很多东西,但我什至不知道我有多接近。
我想像这样得到它:
import json
posts = ["{'author':'John Smith', 'translator':'Jane Doe'}"]
authors = []
translators = []
for post in posts:
double_quotes_post = post.replace("'", '"')
json_data = json.loads(double_quotes_post)
author = json_data.get('author', None)
translator = json_data.get('translator', None)
if author: authors.append(author)
if translator: translators.append(translator)