python-3.x 一个网站对一个1d数组进行编码,结果是一个json字符串,如何解码和查找json数据

uttx8gqw  于 2023-03-20  发布在  Python
关注(0)|答案(1)|浏览(119)

我在调用API时得到的响应如下所示:

{
    "isPacked": true,
    "payload": [
        31,
        139,
        8,
        0,
        0,
        0,
        0,
        0,
        0,
        3,
        117,
        83,
        205,
        110,
        219,
        48,
        12,
        126,
        23,
        158,
        221,
        64,
        146,
        37,
        89,
        214,
        109,
        43,
        48,
        160,
        91,
        119,
        217,
        114,
        105,
        135,
        98,
        144,
        109,
        37,
        49,
        42,
        91,
        129,
        44,
        247,
        7,
        129,
        129,
        157,
        247,
        14,
        123,
        136,
        189,
        210,
        78,
        123,
        140,
        81,
        110,
        210,
        116,
        69,
        106,
        24,
        130,
        77,
        126,
        36,
        63,
        242,
        163,
        118,
        16,
        236,
        48,
        186,
        8,
        58,
        134,
        209,
        102,
        80,
        153,
        24,
        157,
        29,
        64,
        127,
        219,
        65,
        59,
        124,
        49,
        206,
        61,
        30,
        92,
        171,
        224,
        187,
        75,
        95,
        163,
        75,
        240,
        140,
        82,
        89,
        226,
        193,
        213,
        77,
        6,
        209,
        31,
        205,
        76,
        169,
        140,
        146,
        156,
        160,
        185,
        29,
        222,
        127,
        0,
        189,
        50,
        110,
        192,
        224,
        239,
        109,
        3,
        26,
        36,
        167,
        194,
        212,
        149,
        170,
        234,
        138,
        42,
        33,
        75,
        153,
        19,
        129,
        73,
        40,
        100,
        208,
        153,
        80,
        111,
        150,
        143,
        91,
        11,
        90,
        100,
        112,
        219,
        246,
        235,
        198,
        119,
        23,
        115,
        80,
        174,
        86,
        68,
        21,
        21,
        203,
        171,
        178,
        48,
        210,
        54,
        132,
        86,
        5,
        214,
        192,
        32,
        164,
        215,
        154,
        190,
        182,
        71,
        28,
        49,
        164,
        50,
        43,
        4,
        72,
        107,
        155,
        149,
        168,
        26,
        107,
        16,
        215,
        180,
        67,
        76,
        56,
        208,
        84,
        42,
        36,
        220,
        118,
        248,
        89,
        242,
        133,
        228,
        82,
        8,
        206,
        138,
        92,
        169,
        156,
        163,
        3,
        81,
        33,
        46,
        103,
        47,
        48,
        194,
        242,
        51,
        146,
        159,
        81,
        181,
        164,
        76,
        51,
        169,
        41,
        91,
        96,
        123,
        215,
        152,
        206,
        246,
        205,
        105,
        80,
        161,
        185,
        92,
        20,
        5,
        79,
        160,
        173,
        9,
        166,
        3,
        189,
        155,
        230,
        180,
        49,
        213,
        198,
        202,
        38,
        172,
        109,
        252,
        236,
        251,
        33,
        218,
        112,
        241,
        60,
        18,
        83,
        209,
        154,
        75,
        102,
        20,
        169,
        105,
        145,
        35,
        41,
        158,
        186,
        235,
        236,
        48,
        152,
        117,
        42,
        3,
        79,
        211,
        127,
        183,
        111,
        23,
        179,
        30,
        6,
        250,
        118,
        207,
        189,
        153,
        25,
        158,
        251,
        174,
        27,
        123,
        236,
        255,
        202,
        143,
        113,
        3,
        137,
        194,
        58,
        153,
        207,
        175,
        46,
        83,
        86,
        151,
        254,
        118,
        40,
        123,
        125,
        251,
        117,
        99,
        182,
        243,
        132,
        18,
        247,
        136,
        252,
        250,
        189,
        133,
        76,
        216,
        131,
        179,
        166,
        177,
        225,
        211,
        147,
        46,
        175,
        8,
        156,
        22,
        231,
        222,
        7,
        215,
        164,
        30,
        113,
        47,
        14,
        108,
        254,
        252,
        250,
        241,
        247,
        231,
        111,
        60,
        211,
        128,
        252,
        189,
        13,
        160,
        89,
        201,
        153,
        18,
        69,
        142,
        100,
        76,
        109,
        207,
        125,
        131,
        56,
        53,
        189,
        26,
        213,
        139,
        130,
        111,
        207,
        203,
        157,
        218,
        66,
        103,
        239,
        172,
        3,
        141,
        233,
        235,
        57,
        53,
        42,
        70,
        240,
        165,
        71,
        129,
        224,
        206,
        184,
        49,
        121,
        4,
        193,
        231,
        63,
        185,
        236,
        195,
        182,
        13,
        182,
        121,
        41,
        116,
        185,
        36,
        60,
        9,
        141,
        219,
        32,
        11,
        113,
        13,
        83,
        90,
        221,
        135,
        101,
        240,
        126,
        139,
        183,
        134,
        150,
        115,
        146,
        180,
        252,
        31,
        125,
        219,
        167,
        208,
        253,
        5,
        232,
        199,
        238,
        25,
        196,
        36,
        225,
        101,
        57,
        221,
        76,
        255,
        0,
        85,
        168,
        136,
        227,
        126,
        3,
        0,
        0
    ]
}

期望找到能够解码该2D矩阵的解

0g0grzrc

0g0grzrc1#

这只是一个标准的json file或json数据,所以你可以用json模块读取它,如下所示:

import json

with open('my_data.json', 'r') as file:
    d = json.load(file)

# the first item
print(d['isPacked'])  # this is True

# the second item
print(d['payload'])  # this is a long list of integers

结果如下所示:

True
[31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 117, 83, 205, 110, 219, 48, 12, 126, 23, 158, 221, 64, 146, 37, 89, 214, 109, 43, 48, 160, 91, 119, 217, 114, 105, 135, 98, 144, 109, 37, 49, 42, 91, 129, 44, 247, 7, 129, 129, 157, 247, 14, 123, 136, 189, 210, 78, 123, 140, 81, 110, 210, 116, 69, 106, 24, 130, 77, 126, 36, 63, 242, 163, 118, 16, 236, 48, 186, 8, 58, 134, 209, 102, 80, 153, 24, 157, 29, 64, 127, 219, 65, 59, 124, 49, 206, 61, 30, 92, 171, 224, 187, 75, 95, 163, 75, 240, 140, 82, 89, 226, 193, 213, 77, 6, 209, 31, 205, 76, 169, 140, 146, 156, 160, 185, 29, 222, 127, 0, 189, 50, 110, 192, 224, 239, 109, 3, 26, 36, 167, 194, 212, 149, 170, 234, 138, 42, 33, 75, 153, 19, 129, 73, 40, 100, 208, 153, 80, 111, 150, 143, 91, 11, 90, 100, 112, 219, 246, 235, 198, 119, 23, 115, 80, 174, 86, 68, 21, 21, 203, 171, 178, 48, 210, 54, 132, 86, 5, 214, 192, 32, 164, 215, 154, 190, 182, 71, 28, 49, 164, 50, 43, 4, 72, 107, 155, 149, 168, 26, 107, 16, 215, 180, 67, 76, 56, 208, 84, 42, 36, 220, 118, 248, 89, 242, 133, 228, 82, 8, 206, 138, 92, 169, 156, 163, 3, 81, 33, 46, 103, 47, 48, 194, 242, 51, 146, 159, 81, 181, 164, 76, 51, 169, 41, 91, 96, 123, 215, 152, 206, 246, 205, 105, 80, 161, 185, 92, 20, 5, 79, 160, 173, 9, 166, 3, 189, 155, 230, 180, 49, 213, 198, 202, 38, 172, 109, 252, 236, 251, 33, 218, 112, 241, 60, 18, 83, 209, 154, 75, 102, 20, 169, 105, 145, 35, 41, 158, 186, 235, 236, 48, 152, 117, 42, 3, 79, 211, 127, 183, 111, 23, 179, 30, 6, 250, 118, 207, 189, 153, 25, 158, 251, 174, 27, 123, 236, 255, 202, 143, 113, 3, 137, 194, 58, 153, 207, 175, 46, 83, 86, 151, 254, 118, 40, 123, 125, 251, 117, 99, 182, 243, 132, 18, 247, 136, 252, 250, 189, 133, 76, 216, 131, 179, 166, 177, 225, 211, 147, 46, 175, 8, 156, 22, 231, 222, 7, 215, 164, 30, 113, 47, 14, 108, 254, 252, 250, 241, 247, 231, 111, 60, 211, 128, 252, 189, 13, 160, 89, 201, 153, 18, 69, 142, 100, 76, 109, 207, 125, 131, 56, 53, 189, 26, 213, 139, 130, 111, 207, 203, 157, 218, 66, 103, 239, 172, 3, 141, 233, 235, 57, 53, 42, 70, 240, 165, 71, 129, 224, 206, 184, 49, 121, 4, 193, 231, 63, 185, 236, 195, 182, 13, 182, 121, 41, 116, 185, 36, 60, 9, 141, 219, 32, 11, 113, 13, 83, 90, 221, 135, 101, 240, 126, 139, 183, 134, 150, 115, 146, 180, 252, 31, 125, 219, 167, 208, 253, 5, 232, 199, 238, 25, 196, 36, 225, 101, 57, 221, 76, 255, 0, 85, 168, 136, 227, 126, 3, 0, 0]

相关问题