Строка ..
{
"version":"20131101",
"logo":"http://image.aladin.co.kr/img/header/2011/aladin_logo_new.gif",
"title":"알라딘 베스트셀러 리스트 - 철학사",
"link":"http:\/\/www.aladin.co.kr\/shop\/common\/wbest.aspx?BestType=Bestseller&BranchType=1&CID=51441&Year=2019&Month=5&Week=4&partner=openAPI",
"pubDate":"Mon, 27 May 2019 10:33:33 GMT",
"totalResults":955,
"startIndex":1,
"itemsPerPage":10,
"query":"QueryType=BESTSELLER;CategoryId=51441;Year=2019;Month=5;Week=4",
"searchCategoryId":51441,
"searchCategoryName":"철학사",
"item":[
{
"title":"처음 읽는 서양철학사 (개정증보판) - 서양의 대표 철학자 40인과 시작하는 철학의 첫걸음",
"link":"http:\/\/www.aladin.co.kr\/shop\/wproduct.aspx?ItemId=100442130&partner=openAPI&start=api",
"author":"안광복 (지은이)",
}
]
}
Я хочу преобразовать строку в dict.
Это то, что я хочу
Я хочусделать всю строку в словарь, поэтому я хочу получить значение "item"
"item" : [{"title: ", " : ", ... }, {"title: ", " : ", ... }, { "title: ", " : ", ... }]
Я хочу словари (выглядит как словарь, но строка) в списке (выглядит каксписок, но str), поэтому я хочу использовать как словарь
print(decoding_bestseller.find("item",370))
b=decoding_bestseller.split('"item"')
want_str=b[1]
want_str1=want_str.strip(':[]{}')
want_list=want_str1.split(',')
book_dic = {}
for i in range(0,len(want_list)):
in_colon = ":" in want_list[i]
if in_colon:
split_list = want_list[i].split(':')
book_key = split_list[0].strip('""')
book_value = split_list[1].strip('""')
book_dic[book_key] = book_value
Я сделал это, но мне не удалось.
Строка такая {" : ", " : ", "item : [ {"title : ", "link : ", } {"title : ", "link : ", }, " : "}
я хочу сделать {"title : ", "link : ", ...}
РЕАЛЬНЫМ словарем!