国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘

這篇具有很好參考價(jià)值的文章主要介紹了json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

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

json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘,python,json,python

?文章來源地址http://www.zghlxwxcb.cn/news/detail-661038.html

源碼

json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘,python,json,python

輸出

json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘,python,json,python?json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘,python,json,python

?原因:從json讀取的數(shù)據(jù)是text類型,需要將其轉(zhuǎn)化為列表,我這里用的是eval()函數(shù)。源碼修改之后如下:

json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘,python,json,python

?再次輸出正確結(jié)果:

json文件讀取數(shù)據(jù)報(bào)錯(cuò) AttributeError: ‘str‘ object has no attribute ‘items‘,python,json,python

?

?感謝大家的支持和關(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)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Python 使用requests模塊進(jìn)行ip代理時(shí)報(bào)錯(cuò):AttributeError: ‘str‘ object has no attribute ‘get‘

    Python 使用requests模塊進(jìn)行ip代理時(shí)報(bào)錯(cuò):AttributeError: ‘str‘ object has no attribute ‘get‘

    我正在進(jìn)行代理ip的測(cè)試,但報(bào)了這么個(gè)錯(cuò)誤: AttributeError: \\\'str\\\' object has no attribute \\\'get\\\' 從“芝麻代理”獲取代理ip,用這些代理ip訪問百度,如果返回狀態(tài)碼200,就算成功 當(dāng)我執(zhí)行上面的代碼后,報(bào)了這么個(gè)錯(cuò)誤: AttributeError: \\\'str\\\' object has no attribute \\\'get\\\' 經(jīng)過多次排查,確定

    2024年02月03日
    瀏覽(34)
  • 報(bào)錯(cuò)AttributeError: ‘NoneType‘ object has no attribute ‘shape‘

    環(huán)境: python3.6.4 opencv3.4.1.15 運(yùn)行目標(biāo)跟蹤object_tracking文件夾中的mean函數(shù)時(shí)報(bào)錯(cuò)且不顯示視頻結(jié)果 查找原因基本上看見三個(gè) 1.圖片不存在(路徑不存在, 路徑包含中文無法識(shí)別) 2.讀取的圖片內(nèi)容和默認(rèn)讀取時(shí)參數(shù)匹配不匹配。(默認(rèn)讀取的是3通道的彩色圖)例如讀取到的

    2023年04月27日
    瀏覽(33)
  • 【報(bào)錯(cuò)記錄】AttributeError: ‘xxx‘ object has no attribute ‘module‘

    【報(bào)錯(cuò)記錄】AttributeError: ‘xxx‘ object has no attribute ‘module‘

    在跑代碼時(shí),報(bào)出 AttributeError: \\\'InpaintGenerator\\\' object has no attribute \\\'module\\\' 的錯(cuò)誤,如下圖所示: 經(jīng)過一通Debug,定位到是模型保存的位置出錯(cuò),在檢查完路徑等沒有錯(cuò)誤之后。去網(wǎng)上搜尋了一翻資料。終于在一篇博客里找到了解決方案,此處進(jìn)行記錄,以后遇到方便查看。 原來

    2024年02月12日
    瀏覽(25)
  • Python報(bào)錯(cuò):AttributeError: ‘ImageDraw‘ object has no attribute ‘textbbox‘

    報(bào)錯(cuò)原因是pillow的版本過低,導(dǎo)致不能使用 解決方法: 打開Anaconda prompt查看下載列表 刪除原有的pillow: ?從新下載pillow: 如果上面的命令報(bào)錯(cuò)下載不成功嘗試下面的代碼:(從清華鏡像下載pillow) 其他下載鏡像: 清華:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirror

    2024年02月06日
    瀏覽(30)
  • Selenium報(bào)錯(cuò) AttributeError: ‘dict‘ object has no attribute ‘xx‘ (已解決)

    selenium的查找元素并點(diǎn)擊:self.driver.find_element_by_id(\\\"xx\\\").click() 執(zhí)行這句時(shí)報(bào)錯(cuò):AttributeError: \\\'dict\\\' object has no attribute \\\'click\\\',斷言發(fā)現(xiàn),find_element_by_id確實(shí)返回了一個(gè)dict類型。 網(wǎng)上尋找答案后,解決如下: 將安裝的selenium 4.0版本,降為3.141.0版本即可。 參考:https://stackoverflo

    2024年02月12日
    瀏覽(19)
  • 完美解決AttributeError: ‘NoneType‘ object has no attribute ‘split‘ 報(bào)錯(cuò)處理

    已解決AttributeError: ‘NoneType’ object has no attribute ‘split’ 報(bào)錯(cuò)處理 AttributeError: ‘NoneType‘ object has no attribute ‘split‘ 這個(gè)錯(cuò)誤通常出現(xiàn)在使用 NoneType 對(duì)象調(diào)用 split() 方法時(shí)。NoneType 是 Python 中表示空值的類型。 下滑查看解決方法 產(chǎn)生該錯(cuò)誤的原因可能是你沒有正確地初始

    2024年02月12日
    瀏覽(25)
  • 編寫Python 代碼出現(xiàn) AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘ 報(bào)錯(cuò)

    編寫Python 代碼出現(xiàn) AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘ 報(bào)錯(cuò)

    在編寫如下 python 代碼過程中出現(xiàn): AttributeError: ‘DataFrame’ object has no attribute ‘ix’ 錯(cuò)誤截圖: 中文意思: “DataFrame”對(duì)象沒有屬性“ix” 原因是,pandas 的 ‘ix’ 屬性已經(jīng)在最新版本中被棄用了。 pandas的新版本已經(jīng)對(duì)該函數(shù)進(jìn)行了升級(jí)和重構(gòu),可以使用( ‘loc’–可以

    2024年02月15日
    瀏覽(33)
  • 【yolov5 defect報(bào)錯(cuò)】AttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘

    【yolov5 defect報(bào)錯(cuò)】AttributeError: ‘Hardswish‘ object has no attribute ‘inplace‘

    提示:這里簡(jiǎn)述項(xiàng)目相關(guān)背景: 在進(jìn)行利用pytorch進(jìn)行yolov5目標(biāo)檢測(cè)訓(xùn)練的時(shí)候報(bào)錯(cuò)。 主要是activation.py報(bào)錯(cuò),定位到這一行代碼為: def forward(self, input: Tensor) - Tensor: return F.hardswish(input, self.inplace) 原來代碼為: def forward(self, input: Tensor) - Tensor: return F.hardswish(input, self.inplace)

    2024年02月15日
    瀏覽(78)
  • 【報(bào)錯(cuò)】AttributeError: ‘NoneType‘ object has no attribute ‘pyplot_show‘(已解決)

    【報(bào)錯(cuò)】AttributeError: ‘NoneType‘ object has no attribute ‘pyplot_show‘(已解決)

    問題描述:python可視化出現(xiàn)下面報(bào)錯(cuò) 我的原始代碼: 查資料,看到讓更新matplotlib,更新完問題沒有解決 解決方法:加入下面兩行代碼后問題解決 matplotlib.use(‘TkAgg’) import matplotlib.pyplot as plt

    2024年04月16日
    瀏覽(23)
  • Python產(chǎn)生關(guān)鍵詞云報(bào)錯(cuò):AttributeError: ‘ImageDraw‘ object has no attribute ‘textbbox‘

    Python產(chǎn)生關(guān)鍵詞云報(bào)錯(cuò):AttributeError: ‘ImageDraw‘ object has no attribute ‘textbbox‘

    利用jieba snownlp分別分詞,產(chǎn)生云。代碼報(bào)錯(cuò),檢查了以下代碼沒錯(cuò)。 最后在csdn找到了解決方法。 這原來是pillow的版本過低的原因。 辦法如下: 打開Anaconda prompt查看下載列表: pip? list ? 刪除現(xiàn)有的pillow: ?pip uninstall pillow ?下載新版本的pillow: pip install pillow 推薦用

    2024年02月12日
    瀏覽(20)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包