直接上代碼了,搜索就好
#把字典dict轉換成串列,只要鍵,只要值,鍵、值都要,
#選取二維串列的第一列
# coding=utf-8
dict = {"東方航空":'100,101,102,103',
"西南航空":'90,92,97,103',
"國泰航空":'120,180,190,303',
"上海航空":'60,101,178,289',}
#把字典dict轉換成串列
'''
1、建一個空串列
2、回圈讀取字典的內容
3、追加到空串列中
'''
list = []
for type,value in dict.items():
#items 遍歷所有內容
#只要值
tmps = value
list.append(tmps)
#print(list)
print("我是只要值后的處理資料=====》",list)
#結果
#我是只要值后的處理資料=====》 ['100,101,102,103', '90,92,97,103', '120,180,190,303', '60,101,178,289']
dictlist = []
for keys,vlaue in dict.items():
#鍵和值都要
temp = [keys,value]
dictlist.append(temp)
print("我是鍵和值都要后的處理資料=====》",dictlist)
#結果
#我是鍵和值都要后的處理資料=====》 [['東方航空', '60,101,178,289'], ['西南航空', '60,101,178,289'], ['國泰航空', '60,101,178,289'], ['上海航空', '60,101,178,289']]
#選取二維串列的第一列
a = [[1,2,3],[4,5,6],[7,8,9]]
b = [i[0] for i in a]
print(a) #[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(b) #[1, 4, 7]
#輸出結果是
#[[1,2,3],[4,5,6],[7,8,9]]
#[1,4,7]
#未完待續......
未完待續,,,,,,
作者:子欽加油出處:https://www.cnblogs.com/zmdComeOn/
個性簽名:努力生活,努力走路
阿里云拼團:https://www.aliyun.com/1111/home?userCode=f4ee1llo1核2G1M,86一年,229三年;2核4G5M,799三年;2核8G5M,1399三年
騰訊云三月采購計劃特價:https://cloud.tencent.com/act/cps/redirect?redirect=1073&cps_key=15d0b1673287c43fe946626d9f4e2eee&from=console1核2G1M,88一年;1核2G1M,268三年;2核4G5M,998一年;4核8G5M,2888元三年
您的資助是我最大的動力!
金額隨意,歡迎來賞!
如果,想給予我更多的鼓勵,求打
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/429250.html
標籤:Python
