Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获得;TypeError:字符串索引必须是整数;用python打印时;包含数量和单位的列表字典_Python_Serialization - Fatal编程技术网

获得;TypeError:字符串索引必须是整数;用python打印时;包含数量和单位的列表字典

获得;TypeError:字符串索引必须是整数;用python打印时;包含数量和单位的列表字典,python,serialization,Python,Serialization,我有test.txt文件(如下所示) 当我试图打印时,我得到了这个错误 >>> print(content['mass']) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: string indices must be integers 工作正常,并显示全部内容(test.txt) 我需要打印dict中的每个列

我有test.txt文件(如下所示)

当我试图打印时,我得到了这个错误

>>> print(content['mass']) 
Traceback (most recent call last):  
 File "<stdin>", line 1, in <module>
TypeError: string indices must be integers
工作正常,并显示全部内容(test.txt)

我需要打印dict中的每个列表(如质量、温度等),并绘制其中的任意两个

文件内容如下:

{'mass': <Quantity [0.01066337, 0.05677534, 0.01377424, 0.06982872, 0.02665362] solar_mass>, 'temperature': <[values ... ] unit>}
{'mass':,'temperature':}
完整内容文件:

{'mass': <Quantity [0.01066337, 0.05677534, 0.01377424, 0.06982872, 0.02665362,
           0.05278109, 0.01705602, 0.01321568, 0.08957726, 0.01409967,
           0.02680093, 0.04329349, 0.04019967, 0.01633035, 0.09329267,
           0.09963128, 0.04351358, 0.07735598, 0.02380135, 0.02242677,
           0.03210654, 0.08636837, 0.02273623, 0.08528297, 0.07963256,
           0.01457712, 0.07067075, 0.03672347, 0.08830624, 0.0152433 ,
           0.02692899, 0.06610553, 0.09237312, 0.01470838, 0.06389854,
           0.0367586 , 0.01463151, 0.05156612, 0.09061456, 0.02097923,
           0.09724939, 0.01442857, 0.04258596, 0.09389821, 0.04595303,
           0.01288873, 0.09977905, 0.08107244, 0.07191315, 0.01770304,
           0.080393  , 0.02020766, 0.07458504, 0.01695185, 0.07393091,
           0.03053152, 0.06589851, 0.02035323, 0.07618899, 0.03820138,
           0.02377403, 0.07995724, 0.04570385, 0.02277475, 0.01927913,
           0.02415907, 0.01820019, 0.04897082, 0.05023911, 0.02736103,
           0.05118501, 0.05433449, 0.05497384, 0.0278658 , 0.0109119 ,
           0.04103063, 0.05278137, 0.08110729, 0.02117512, 0.02299667,
           0.02712591, 0.09289156, 0.07933846, 0.07723336, 0.07550681,
           0.09140791, 0.05044324, 0.04048182, 0.0540212 , 0.06348042,
           0.09851312, 0.06866901, 0.04383336, 0.06000141, 0.06026228,
           0.09245798, 0.06652555, 0.08638328, 0.02669351, 0.03291363,
           0.09498578, 0.07123481, 0.01734788, 0.06394011, 0.09080883,
           0.0100093 , 0.05614301, 0.08463198, 0.08348169, 0.0695272 ,
           0.012756  , 0.08004025, 0.042433  , 0.04228984, 0.05852984,
           0.09786057, 0.09222483, 0.05554798, 0.02833528, 0.05775946,
           0.04866883, 0.08642554, 0.05625195, 0.04145988, 0.03118205,
           0.06150846, 0.03043129, 0.08140125, 0.0371213 , 0.08422178,
           0.04447278, 0.05010288, 0.03013005, 0.07293837, 0.04287462,
           0.07925233, 0.03597007, 0.06064241, 0.01506324, 0.01661757,
           0.09065556, 0.01877721, 0.06181287, 0.01797611, 0.08751541,
           0.06245063, 0.05643477, 0.09667603, 0.02816646, 0.05963242,
           0.09114687, 0.08555436, 0.03389574, 0.03619514, 0.09107117,
           0.08513269, 0.02986811, 0.06354284, 0.03119169, 0.02294978,
           0.08086929, 0.07718417, 0.03123856, 0.03509633, 0.05837078,
           0.02374362, 0.06490901, 0.05722849, 0.05868046, 0.01302157,
           0.01879107, 0.07831512, 0.04077195, 0.02944109, 0.06633705,
           0.09150163, 0.03014493, 0.07650354, 0.05166767, 0.0630273 ,
           0.04772543, 0.0354305 , 0.02018854, 0.09507716, 0.02150221,
           0.01615494, 0.06707219, 0.06575294, 0.05319418, 0.06806339,
           0.084564  , 0.06717039, 0.07972018, 0.06372022, 0.03449891,
           0.01062518, 0.0362224 , 0.06631852, 0.06794747, 0.07164968] solMass>,
 'age': <Quantity [2.1892995 , 0.17371445, 6.37350567, 3.65552583, 0.26690645,
           9.01274312, 9.5712514 , 4.12433204, 1.46197905, 6.69672667,
           2.60662951, 0.07088385, 5.68504611, 2.14170039, 8.25031197,
           1.05353222, 6.38848764, 4.91127832, 4.83363973, 1.06507071,
           8.91887495, 9.04766237, 6.77889849, 9.2907544 , 9.85479148,
           2.02304717, 3.2270554 , 9.36069897, 8.1881205 , 8.26326698,
           4.24937976, 5.43265177, 1.23439319, 0.66178519, 7.30850369,
           8.53579481, 0.58917658, 9.52785688, 8.78128074, 7.49955993,
           6.07008997, 2.43334746, 9.15192905, 5.34271923, 1.03902797,
           7.85382611, 9.07929136, 2.34516092, 4.0336831 , 6.9754011 ,
           1.65513417, 5.78941649, 6.28545569, 7.14168201, 4.5552691 ,
           6.21132475, 6.81369173, 1.74626285, 9.87199907, 3.68096459,
           5.70725541, 8.50758903, 4.5958371 , 9.26271041, 9.21219332,
           1.12404491, 8.46718892, 2.41106556, 9.5383536 , 2.845751  ,
           5.48186263, 3.75960932, 9.46408245, 3.070541  , 5.14349759,
           6.72742338, 2.056287  , 8.26982877, 3.23218309, 4.17451665,
           5.77088167, 0.44298759, 9.65296989, 2.61752721, 9.13504304,
           7.98373538, 5.71220366, 1.56916865, 1.97688569, 1.91507324,
           9.17263502, 1.77701376, 4.55412645, 3.2627102 , 7.35668915,
           2.50479129, 2.61109961, 6.37928278, 4.95950159, 3.05026315,
           4.05514457, 0.08672433, 2.86609243, 1.35325359, 3.42583719,
           4.26484596, 5.1162449 , 4.85971091, 4.44955176, 2.23475404,
           3.31668938, 8.43803181, 0.72360653, 4.15507274, 0.87411426,
           7.75213716, 4.6793922 , 7.48000041, 5.72125433, 1.31397429,
           5.95206492, 8.58636847, 5.89774647, 3.26018283, 8.27834433,
           4.00586172, 5.53028026, 4.79525327, 3.29217389, 4.87280459,
           3.7335077 , 3.30432489, 3.60355157, 9.34549498, 6.49931121,
           0.02732216, 6.94381144, 5.90679801, 3.16357294, 7.82961274,
           0.0888311 , 7.9029332 , 4.33901607, 5.51927395, 6.53654137,
           7.64875188, 3.09088845, 6.17206639, 4.5635939 , 1.12640628,
           6.55772591, 0.8635738 , 8.86321633, 6.58032887, 0.57264661,
           9.99113685, 0.83339148, 6.32905049, 9.21722392, 1.65153675,
           4.29805491, 4.29669901, 5.58498365, 9.08169993, 6.42132207,
           2.0412622 , 4.7042499 , 8.45610063, 5.53653754, 4.27634556,
           0.98283569, 4.70564712, 4.85030912, 4.43987977, 2.20253426,
           5.61759252, 7.5305766 , 9.28187195, 0.06004595, 0.8131256 ,
           0.9932211 , 1.47332778, 1.44624897, 9.23842621, 5.34899458,
           8.43612797, 9.4825792 , 5.94245213, 6.74007551, 6.20404917,
           9.53766677, 4.60019672, 1.59700463, 5.52334977, 0.48772997,
           0.59965089, 1.75955369, 9.56138032, 1.04756037, 3.91171088] Gyr>, 'temperature': <Quantity [ 416.26187575, 2386.00147856,  356.96775964, 1611.48635911,
           1386.90459789,  843.45377056,  359.56621029,  397.98698621,
           2615.60719944,  356.35902942,  696.73157636, 2452.07321025,
            738.22537858,  532.80565595, 2677.89432543, 2778.16848831,
            769.31944774, 2151.4339527 ,  533.16952309,  812.50564763,
            548.1938236 , 2513.85620097,  471.13610308, 2481.15025828,
           2297.11805108,  508.33419459, 1725.63923115,  602.54069179,
           2572.14755174,  351.02698579,  599.78662322, 1332.30425907,
           2664.27485445,  715.27835447, 1157.7390599 ,  617.72498514,
            742.04731718,  811.52591929, 2633.86501557,  434.9693978 ,
           2741.4568123 ,  480.34396454,  686.744989  , 2686.61464287,
           1416.43680536,  325.36847056, 2782.35910147, 2382.15547751,
           1761.66710638,  401.58797383, 2375.15628236,  456.84485622,
           1960.34206079,  389.02690439, 1909.10788514,  582.38959148,
           1253.47061676,  655.9560554 , 2071.71727096,  807.75308367,
            508.31655569, 2318.63547143,  880.95939104,  431.89009998,
            389.83994036,  840.95773606,  386.29226905, 1148.60436432,
            789.50516397,  686.72298902,  930.60237286, 1107.69977761,
            869.80628035,  678.32474609,  337.22647863,  719.64135682,
           1299.92452458, 2354.81635642,  560.35816002,  546.26491365,
            550.48207955, 2728.27478396, 2277.28716021, 2166.3338627 ,
           2028.72650099, 2646.76330972,  907.07025528, 1112.10342809,
           1347.40455825, 1567.69512142, 2762.24673578, 1792.33516425,
            850.53825842, 1270.41170997, 1025.53432709, 2663.39115409,
           1561.35583681, 2513.28960355,  568.35332647,  764.20122094,
           2704.05935833, 2789.71414994,  508.66726781, 1748.71166657,
           2636.13556182,  335.90296155, 1040.7441679 , 2460.87911061,
           2429.70209659, 1757.52438765,  416.53092797, 2322.72218894,
           1472.63533413,  847.29923108, 1827.91530672, 2751.58852168,
           2658.86923054,  932.96214473,  567.10026795, 1608.78268184,
            867.7687031 , 2515.42004061, 1004.56537506,  898.84784151,
            546.83257922, 1228.64851226,  599.80749478, 2363.87785858,
            818.03791184, 2448.3783556 ,  917.2780149 , 1062.48713029,
            678.01980883, 1699.94999111,  755.65919285, 2918.00441238,
            640.80652735, 1097.67818411,  455.0697186 ,  374.90100478,
           2919.23401673,  400.97259608, 1221.76007185,  432.21978007,
           2547.58809003, 1092.25936545, 1224.11062078, 2732.25980845,
            603.32307638, 1729.78873919, 2641.86202827, 2529.80624052,
            573.36519488,  653.1220142 , 2687.00147158, 2476.83545148,
           1067.09489353, 1186.50146867,  531.10784434,  723.71093433,
           2352.11261182, 2145.45144949,  610.27363595,  585.76505168,
           1021.59377921,  695.08881158, 1326.15404201,  933.61651678,
           1066.31164386,  391.34211341,  737.96295138, 2213.58596372,
            780.74166508,  625.66321926, 1604.59456116, 2647.29238788,
            546.95277285, 2091.59457771, 2636.78384296, 1950.52489595,
           1484.64961828, 1018.81913319,  690.23845654, 2707.05845721,
            485.87384115,  361.21491645, 1197.21167289, 1289.88457879,
            916.51388128, 1367.72546396, 2459.51962535, 1426.2466385 ,
           2345.90602429, 1233.03426045, 1420.10028775,  603.3961445 ,
            979.86162211, 1167.48046769, 1996.95643785, 1759.6332142 ] K>, 'gravity': <Dex [4.43710182, 4.965187  , 4.5960181 , 5.43935524, 4.77599392,
      5.36645319, 4.71685808, 4.5631087 , 5.28746289, 4.60912155,
      4.92292931, 4.73522324, 5.1859695 , 4.65413841, 5.27461287,
      5.24749696, 5.23839782, 5.38287012, 4.88123687, 4.7978376 ,
      5.06587143, 5.31138048, 4.86481419, 5.31825235, 5.35742248,
      4.59283847, 5.42541489, 5.14719842, 5.29932345, 4.65409788,
      4.94470474, 5.45260548, 5.27588952, 4.558575  , 5.45716882,
      5.14497198, 4.55072716, 5.35471333, 5.28628722, 4.8221192 ,
      5.25810337, 4.59295229, 5.23605709, 5.27209735, 5.17053945,
      4.56689609, 5.24704209, 5.33165214, 5.43725938, 4.72922773,
      5.32972958, 4.79516682, 5.41802867, 4.70686194, 5.42131465,
      5.02688942, 5.46371964, 4.76247288, 5.39988976, 5.13962788,
      4.8853597 , 5.35351361, 5.25370809, 4.87296808, 4.78071025,
      4.8384147 , 4.7483346 , 5.25428576, 5.33904289, 4.93784239,
      5.32980831, 5.34280863, 5.39371378, 4.95096254, 4.47277291,
      5.20372326, 5.28786486, 5.34553068, 4.80229852, 4.85641286,
      4.95883889, 5.21125042, 5.36097707, 5.37256552, 5.40842553,
      5.28281229, 5.32288574, 5.12740498, 5.29872025, 5.35763516,
      5.25223846, 5.37453344, 5.22803649, 5.3843215 , 5.43732776,
      5.27730831, 5.39646086, 5.31128667, 4.94587991, 5.04578314,
      5.26737666, 4.83639934, 4.69458324, 5.33220018, 5.28474856,
      4.42491336, 5.38056442, 5.32188551, 5.32767791, 5.39734114,
      4.53849927, 5.35272672, 5.0955432 , 5.20069748, 5.2635995 ,
      5.25519359, 5.27922436, 5.3892347 , 4.98281909, 5.29584768,
      5.30308228, 5.31102091, 5.38680781, 5.17573485, 5.04666149,
      5.4074127 , 5.02195334, 5.34278556, 5.11902518, 5.32457575,
      5.22414132, 5.28793297, 5.00070561, 5.45733048, 5.22986539,
      4.50000751, 5.12582843, 5.42935598, 4.62285578, 4.69846184,
      4.85026837, 4.76323393, 5.41555175, 4.7319106 , 5.3042116 ,
      5.45138916, 5.35223793, 5.26047562, 4.97242888, 5.29769635,
      5.28395234, 5.29203278, 5.09791617, 5.12790729, 5.24523198,
      5.31921069, 4.93450972, 5.44844625, 5.04968515, 4.82351901,
      5.34430774, 5.38237638, 5.03749854, 5.11934352, 5.41263898,
      4.84788074, 5.43744925, 5.41320623, 5.40904518, 4.55653996,
      4.70295737, 5.3709984 , 5.18855237, 4.9959135 , 5.38151548,
      5.28240382, 5.02444936, 5.39593188, 4.7121672 , 5.27456645,
      5.18684626, 5.05459057, 4.7523688 , 5.26671687, 4.8279413 ,
      4.68526605, 5.48585731, 5.45572803, 5.35943445, 5.46878134,
      5.32285266, 5.44626453, 5.33487488, 5.44204577, 4.96778534,
      4.39178975, 5.07501785, 5.4823541 , 5.32855791, 5.43496633] dex(cm / s2)>, 'luminosity': <Dex [-6.54711661, -3.31607959, -6.86248067, -4.381449  , -4.39742816,
      -5.55510124, -6.87861382, -6.65725929, -3.28000489, -6.8685772 ,
      -5.73806679, -3.15642613, -5.72497634, -6.15085019, -3.20879829,
      -3.08971297, -5.67130648, -3.77869081, -6.21263909, -5.42361876,
      -6.21936147, -3.38884433, -6.43139063, -3.42402442, -3.62712937,
      -6.22047683, -4.24385183, -6.07733083, -3.3271961 , -6.90594949,
      -6.01797205, -4.74899511, -3.22321687, -5.58886949, -5.01236152,
      -6.03170168, -5.51942472, -5.62053792, -3.26178624, -6.56311215,
      -3.13354733, -6.32337469, -5.87454898, -3.19763512, -4.51896506,
      -7.0225412 , -3.08617018, -3.53016605, -4.21292318, -6.68194926,
      -3.53714714, -6.46649762, -3.99162757, -6.733638  , -4.04494859,
      -6.09690661, -4.8674517 , -5.80211144, -3.8682314 , -5.54462774,
      -6.30025681, -3.60514918, -5.42935759, -6.59095371, -6.74941265,
      -5.37202798, -6.75730693, -4.93888066, -5.66396037, -5.76911782,
      -5.36049636, -5.04504737, -5.51129412, -5.79566146, -6.9386513 ,
      -5.77776669, -4.72492306, -3.56399378, -6.09817542, -6.16062514,
      -6.17801414, -3.11465238, -3.64734012, -3.75730692, -3.91705852,
      -3.24603817, -5.40442467, -4.95138337, -4.66342371, -4.38901353,
      -3.10942375, -4.13912096, -5.4831754 , -4.80545391, -5.22876444,
      -3.22468225, -4.41449109, -3.38886772, -6.11645229, -5.61137395,
      -3.17674537, -2.8170494 , -6.24545807, -4.17064934, -3.25764594,
      -6.93694802, -5.17684481, -3.44491303, -3.47885876, -4.19060971,
      -6.56817022, -3.60084444, -4.41079121, -5.4783194 , -4.06357302,
      -3.12177758, -3.23049961, -5.38037703, -6.13137589, -4.32345767,
      -5.47733405, -3.38707704, -5.24384505, -5.35946433, -6.21719022,
      -4.87579054, -6.04212794, -3.55267083, -5.51445944, -3.45857056,
      -5.34174391, -5.09771833, -5.81223993, -4.28874553, -5.70026866,
      -2.35593355, -5.95892139, -5.09979207, -6.42928691, -6.79814261,
      -2.6467564 , -6.69380454, -4.89155381, -6.55031118, -3.35257284,
      -5.11776702, -4.86454502, -3.14429899, -6.01595667, -4.18544193,
      -3.25153371, -3.36267718, -6.14961411, -5.92533787, -3.18368679,
      -3.42883108, -4.96202439, -4.9633597 , -6.27078878, -5.64019033,
      -3.56576012, -3.78405704, -6.01633689, -6.11851715, -5.22451544,
      -5.71979944, -4.74979851, -5.39028779, -5.14409858, -6.68613937,
      -5.57280601, -3.71194278, -5.62435596, -5.95705735, -4.35332226,
      -3.24467801, -6.20912901, -3.84584977, -2.93013877, -3.92950563,
      -4.43707326, -5.08864745, -5.70709839, -3.17410724, -6.36487176,
      -6.86190098, -4.96181435, -4.81065936, -5.40014859, -4.70692963,
      -3.44756316, -4.61734128, -3.56751066, -4.88890729, -4.43576264,
      -5.8584977 , -5.16727488, -5.00693922, -3.9099617 , -4.21418168] dex(solLum)>, 'radius': <Quantity [0.10367149, 0.12970977, 0.09806314, 0.08334739, 0.11069133,
           0.0785519 , 0.0947761 , 0.09972202, 0.11253834, 0.09770918,
           0.09378137, 0.14773965, 0.08453269, 0.09968327, 0.11695712,
           0.12455847, 0.08275767, 0.0936908 , 0.09294707, 0.0986552 ,
           0.08713584, 0.10789239, 0.09248596, 0.10637093, 0.09825089,
           0.10104164, 0.08504679, 0.08464685, 0.11061464, 0.09637859,
           0.09190295, 0.07988967, 0.1158526 , 0.10563037, 0.07816749,
           0.08489901, 0.10637899, 0.07869662, 0.11373903, 0.0932158 ,
           0.12170452, 0.1005596 , 0.0821066 , 0.11768421, 0.09217953,
           0.09805614, 0.12473543, 0.10191273, 0.08447081, 0.09530858,
           0.10160875, 0.09444041, 0.08815973, 0.09569271, 0.08732745,
           0.08905792, 0.07887032, 0.09806598, 0.09133991, 0.08690757,
           0.0924379 , 0.09891271, 0.08369776, 0.09158276, 0.09361303,
           0.0977509 , 0.09445411, 0.08667936, 0.07912382, 0.0931945 ,
           0.08120554, 0.08227846, 0.07766363, 0.09268461, 0.10043724,
           0.08366547, 0.0864166 , 0.1005401 , 0.095778  , 0.09392486,
           0.0907937 , 0.12508328, 0.09765291, 0.09454306, 0.08999446,
           0.11469276, 0.08126817, 0.09063489, 0.08625252, 0.08719552,
           0.12321906, 0.08885533, 0.08431779, 0.08225772, 0.07737114,
           0.11595455, 0.08530861, 0.10791331, 0.09144224, 0.09012625,
           0.11898958, 0.16845583, 0.09814612, 0.09019986, 0.11397261,
           0.10157242, 0.07998144, 0.10551523, 0.10407616, 0.08716712,
           0.10071855, 0.09905593, 0.09645754, 0.08536378, 0.09373547,
           0.12243711, 0.11567444, 0.07851749, 0.09029243, 0.08965263,
           0.08158881, 0.1079726 , 0.07934098, 0.08690498, 0.08786349,
           0.08096173, 0.0894523 , 0.1010277 , 0.08772868, 0.10493585,
           0.08532489, 0.0844292 , 0.09111147, 0.0836555 , 0.08295352,
           0.26205706, 0.08588099, 0.0784086 , 0.09935163, 0.09563672,
           0.1877203 , 0.09432879, 0.08043013, 0.09581965, 0.10950281,
           0.07766852, 0.0827943 , 0.1210171 , 0.09109304, 0.09096926,
           0.11437898, 0.10932089, 0.08619882, 0.0859307 , 0.11914385,
           0.10616047, 0.09732112, 0.07872167, 0.08755052, 0.09706002,
           0.10049042, 0.09357949, 0.08895979, 0.08551933, 0.07836048,
           0.09607737, 0.08046654, 0.07748946, 0.07892331, 0.09974402,
           0.10073852, 0.09569109, 0.08492312, 0.09065687, 0.08662187,
           0.11480539, 0.08872791, 0.09196292, 0.16573688, 0.09601582,
           0.09229225, 0.09223402, 0.09873764, 0.11909924, 0.09388137,
           0.09571571, 0.07767059, 0.07943153, 0.07967868, 0.07969055,
           0.10536442, 0.08108227, 0.10053525, 0.07934334, 0.10084415,
           0.10893685, 0.09110087, 0.077487  , 0.09319972, 0.08454794] solRad>}
{'mass':,
‘年龄’:,‘温度’:,‘重力’:,‘光度’:,‘半径’:}
试试这个:

import json

json_data = json.loads(content)

print(json_data["mass"])

内容
是字符串,而不是字典。我想您需要首先解析它。“TypeError:字符串索引必须是整数”这意味着它听起来就是这样。如果您被告知用于字符串的索引有问题,这意味着您要索引的对象是字符串。您为这本
词典
添加了标签,这意味着您希望将其索引到词典中。您拥有的字符串看起来像字典的语法,但它仍然不是字典。你必须做字典。真正的问题是为什么你的文件看起来像这样?似乎您想象过,您可以盲目地将任何数据结构的字符串表示形式写入文件中,然后再读取它并获取数据结构。它不是这样工作的,首先是因为不是每个对象都是为它设计的,其次是因为您仍然需要告诉Python字符串表示其他内容。其他人无法告诉您如何处理这些数据,因为
表示代码中我们看不到的内容。您需要从头开始并解释整个问题,包括向我们展示原始数据来源的代码,以及解释您希望通过创建文件来解决的问题。代码可用,但文档有点不符合最新的更改。一般来说,如果模拟的输出类似于{'mass':,'temperature':},我可以只单独打印列表,还是必须修改输出以使其工作???OP的文件内容不是有效的JSON。
import json

json_data = json.loads(content)

print(json_data["mass"])