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

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

python2.7 list轉(zhuǎn)成成元組處理方法

python2.7 list轉(zhuǎn)成成元組處理方法

holdtom 2018-09-07 22:22:30
python2.7下現(xiàn)有列表:[{'storage1': '0000:05:00.1', 'storage0': '0000:05:00.0', 'data1': '0000:04:00.1', 'control1': '0000:02:00.1', 'control0': '0000:02:00.0', 'data0': '0000:04:00.0'}, {'storage1': '0000:03:00.1', 'storage0': '0000:03:00.0', 'data1': '0000:06:00.1', 'control1': '0000:81:00.1', 'control0': '0000:81:00.0', 'data0': '0000:06:00.0'}, {'storage1': '0000:03:00.1', 'storage0': '0000:03:00.0', 'data1': '0000:06:00.1', 'control1': '0000:81:00.1', 'control0': '0000:81:00.0', 'data0': '0000:06:00.0'}, {'storage1': '0000:04:00.1', 'storage0': '0000:04:00.0', 'data1': '0000:81:00.1', 'control1': '0000:01:00.1', 'control0': '0000:01:00.0', 'data0': '0000:81:00.0'}, {'storage1': '0000:08:00.1', 'storage0': '0000:08:00.0', 'data1': '0000:05:00.1', 'control1': '0000:02:00.1', 'control0': '0000:02:00.0', 'data0': '0000:05:00.0'}]想要以{"nic_list":[('0000:05:00.1','0000:05:00.1'),('0000:05:00.0','0000:05:00.0')]}....這種結(jié)構(gòu)顯示所有的數(shù)據(jù),請問如何處理呢,謝謝!
查看完整描述

1 回答

?
蝴蝶刀刀

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

l = [{'storage1': '0000:05:00.1', 'storage0': '0000:05:00.0', 'data1': '0000:04:00.1', 'control1': '0000:02:00.1',      'control0': '0000:02:00.0', 'data0': '0000:04:00.0'},
     {'storage1': '0000:03:00.1', 'storage0': '0000:03:00.0', 'data1': '0000:06:00.1', 'control1': '0000:81:00.1',      'control0': '0000:81:00.0', 'data0': '0000:06:00.0'},
     {'storage1': '0000:03:00.1', 'storage0': '0000:03:00.0', 'data1': '0000:06:00.1', 'control1': '0000:81:00.1',      'control0': '0000:81:00.0', 'data0': '0000:06:00.0'},
     {'storage1': '0000:04:00.1', 'storage0': '0000:04:00.0', 'data1': '0000:81:00.1', 'control1': '0000:01:00.1',      'control0': '0000:01:00.0', 'data0': '0000:81:00.0'},
     {'storage1': '0000:08:00.1', 'storage0': '0000:08:00.0', 'data1': '0000:05:00.1', 'control1': '0000:02:00.1',      'control0': '0000:02:00.0', 'data0': '0000:05:00.0'}]

d = {'nic_list': []}

all_poi = []for item in l:    for k, v in item.items():        if 'storage' in k:
            all_poi.append(v)for i, j in zip(all_poi, all_poi):
    a = (i, j)
    d['nic_list'].append(a)

print(d)
運(yùn)行結(jié)果 {'nic_list': [('0000:05:00.1', '0000:05:00.1'), ('0000:05:00.0', '0000:05:00.0'), ('0000:03:00.1', '0000:03:00.1'), ('0000:03:00.0', '0000:03:00.0'), ('0000:03:00.1', '0000:03:00.1'), ('0000:03:00.0', '0000:03:00.0'), ('0000:04:00.1', '0000:04:00.1'), ('0000:04:00.0', '0000:04:00.0'), ('0000:08:00.1', '0000:08:00.1'), ('0000:08:00.0', '0000:08:00.0')]}


查看完整回答
反對 回復(fù) 2018-09-08
  • 1 回答
  • 0 關(guān)注
  • 901 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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