第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將以下數(shù)據(jù)存儲在適當(dāng)?shù)臄?shù)據(jù)結(jié)構(gòu)中?

如何將以下數(shù)據(jù)存儲在適當(dāng)?shù)臄?shù)據(jù)結(jié)構(gòu)中?

皈依舞 2023-06-28 15:24:33
我有以下輸入數(shù)據(jù),需要存儲在適當(dāng)?shù)臄?shù)據(jù)結(jié)構(gòu)中。ElectronicsElectronics > Arcade EquipmentElectronics > Arcade Equipment > Basketball Arcade GamesElectronics > Arcade Equipment > Video Game Arcade CabinetsElectronics > AudioElectronics > Audio > Audio AccessoriesElectronics > Audio > Audio Accessories > Audio & Video Receiver AccessoriesElectronics > Audio > Audio Accessories > Headphone & Headset AccessoriesElectronics > Audio > Audio Accessories > Headphone & Headset Accessories > Headphone Cushions & TipsApparel & Accessories > Clothing > Activewear > Hunting Clothing > Hunting & Tactical PantsApparel & Accessories > Clothing > Activewear > Martial Arts ShortsApparel & Accessories > Clothing > Activewear > Motorcycle Protective ClothingApparel & Accessories > Clothing > Baby & Toddler ClothingAnimals & Pet Supplies > Pet Supplies > Pet Grooming Supplies > Pet Nail Polish其中應(yīng)該提供以下信息。我已經(jīng)按照以下方式使用 python3 實(shí)現(xiàn)了,其時間復(fù)雜度為 O(n),其中 n 是文件中的行數(shù)。是否有其他有效的解決方案來存儲上述信息。def get_data(file_path):    try:        if not os.path.exists(file_path):     # check file exist or not            raise FileNotFoundError    except FileNotFoundError:        print('please provide valid file path')        exit()    inventory = {}    with open(file=file_path, mode='r', encoding='utf-8') as file_descr:        try:            for line in file_descr:                line = line.strip()                llist = line.split('>')         # list of keys                for i in range(1, len(llist) + 1):     # check entry of each possible key in inventory                    key = ('>'.join(llist[:i])).strip()                    if inventory.get(key):                        inventory[key] += 1                    else:                        inventory[key] = 1        except Exception as e:            print('not able to read content', e)            exit()    return inventory
查看完整描述

1 回答

?
幕布斯7119047

TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個贊

為您的模型創(chuàng)建類并使用樹結(jié)構(gòu)。



查看完整回答
反對 回復(fù) 2023-06-28
  • 1 回答
  • 0 關(guān)注
  • 173 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號