trans_width_table表如下:
{frozenset({2}): {3: 250, 2.5: 100, 1.5: 25, 2: 50, 1.8: 50, 2.75: 200, 5: 350, 4: 350, 2.3: 100, 4.5: 350, 3.5: 300}, frozenset({1, 3, 4, 5}): {2.5: 75, 2.75: 100, 1.5: 25, 4: 300, 3.5: 200, 4.5: 300, 3: 100, 5: 300, 2.3: 50, 2: 25, 1.8: 25}, frozenset({8, 9, 6, 7}): {5: 250, 1.8: 25, 1.5: 25, 4: 150, 2.3: 25, 2: 25, 2.75: 50, 2.5: 50, 3: 50, 4.5: 150, 3.5: 50}}
25
?文章來源地址http://www.zghlxwxcb.cn/news/detail-661038.html
源碼
輸出
?
?原因:從json讀取的數(shù)據(jù)是text類型,需要將其轉(zhuǎn)化為列表,我這里用的是eval()函數(shù)。源碼修改之后如下:
?再次輸出正確結(jié)果:
?
?感謝大家的支持和關(guān)注?。?mark hidden color="red">文章來源:http://www.zghlxwxcb.cn/news/detail-661038.html
?
到了這里,關(guān)于json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!