@xcv0

Как достать эту информацию из строки?

{"module":[{"destCountry":"Russia","detailList":[{"actionCode":"SC_INBOUND_SUCCESS","desc":"Inbound in sorting center","descTitle":"Carrier note:","group":{"currentIconUrl":"https:\/\/img.alicdn.com\/imgextra\/i4\/O1CN01MZ8JBd1yVWTLbfuHQ_!!6000000006584-2-tps-48-48.png","historyIconUrl":"https:\/\/img.alicdn.com\/imgextra\/i1\/O1CN01fPAIee1a5pTIgKnuB_!!6000000003279-2-tps-48-48.png","nodeCode":"AE_GROUP_SC_PROCESSING","nodeDesc":"In transit"},"standerdDesc":"[Fenggang Town] Processing at sorting center","time":1663667668000,"timeStr":"2022-09-20 17:54:28","timeZone":"GMT+8"},{"actionCode":"PU_PICKUP_SUCCESS","desc":"Accepted by carrier","descTitle":"Carrier note:","group":{"currentIconUrl":"https:\/\/img.alicdn.com\/imgextra\/i4\/O1CN01MZ8JBd1yVWTLbfuHQ_!!6000000006584-2-tps-48-48.png","historyIconUrl":"https:\/\/img.alicdn.com\/imgextra\/i1\/O1CN01fPAIee1a5pTIgKnuB_!!6000000003279-2-tps-48-48.png","nodeCode":"AE_GROUP_PU_PROCESSING","nodeDesc":"In transit"},"standerdDesc":"Received by logistics company","time":1663665868000,"timeStr":"2022-09-20 17:24:28","timeZone":"GMT+8"}],"globalEtaInfo":{"deliveryMaxTime":1666688269401,"deliveryMinTime":1666688269401,"etaDesc":"Estimated delivery by:"},"latestTrace":{"actionCode":"SC_INBOUND_SUCCESS","desc":"Inbound in sorting center","descTitle":"Carrier note:","group":{"currentIconUrl":"https:\/\/img.alicdn.com\/imgextra\/i4\/O1CN01MZ8JBd1yVWTLbfuHQ_!!6000000006584-2-tps-48-48.png","historyIconUrl":"https:\/\/img.alicdn.com\/imgextra\/i1\/O1CN01fPAIee1a5pTIgKnuB_!!6000000003279-2-tps-48-48.png","nodeCode":"AE_GROUP_SC_PROCESSING","nodeDesc":"In transit"},"standerdDesc":"[Fenggang Town] Processing at sorting center","time":1663667668000,"timeStr":"2022-09-20 17:54:28","timeZone":"GMT+8"},"lgOrderCode":"LP00532723579066","mailNo":"ZH712xxxxx","mailNoSource":"AE","mailType":"Economy","mailTypeDesc":"Economy shipping doesn't include tracking after a package has been handed to a destination country\/region's carrier.","originCountry":"Mainland China","processInfo":{"progressPointList":[{"light":true,"pointName":"Mainland China"},{"pointName":"Russia"},{"pointName":"Destination city","reload":true},{"pointName":"Delivered"}],"progressRate":0.125,"progressStatus":"NORMAL","type":"CROSS"},"status":"DELIVERING","statusDesc":"Delivering"}],"success":true}


Как из этого достать значение standerdDesc?
  • Вопрос задан
  • 107 просмотров
Решения вопроса 1
sheerluck
@sheerluck
import json

with open("ваш_файл.json") as f:
    content = f.read()
for module in json.loads(content)["module"]:
    detail_lists = module["detailList"]
    for dl in detail_lists:
        print(dl["standerdDesc"])

# напечатает:
[Fenggang Town] Processing at sorting center
Received by logistics company
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
@itsoftoff
Любой json код это по факту словарь просто указывай индексы i["modules"][и так дальше]
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы