陳冠辰python:集合set串列或清單list字典dictionary元組tuple 3月 27, 2023
h1{background-color: purple; color: white; padding: 10px}
h2{background-color: blue; color: white; padding: 5px; border-radius: 20px;}
pre{background-color:tomato; color: white; font-size: 20px; line-height: 1.2;}
w3schools截圖
w3schools程式碼
#劉任昌 集合{},字典{key:value,},元組(),清單]
s= {"台積電", "鴻海", "聯發科"}
t= ("台積電", "鴻海", "聯發科")
list= ["台積電", "鴻海", "聯發科"]
d= {2330:"台積電",2317:"鴻海",2454:"聯發科"}
print("型態" + str(type(s)) + str(s))
print("型態" + str(type(t)) + str(t))
print("型態" + str(type(d)) + str(d))
print("型態" + str(type(list)) + str(list))
#字串與字串才能+所以要用str轉成字串
i = 0
for a in list:
i = i+1
print("台灣第" + str(i) + "大的公司是")
print(" " + a)
(x,y,z) = t
print("拆掉t後列出 "+ x + " " +y +" "+z)
print("集合的index找出聯發科位置" + str(t.index("聯發科")))
327集合
回覆刪除https://www.facebook.com/robertjcliu/posts/pfbid0Cgi2UHdrmP4z8rpbM61RTgcd9tsVsbdeBKU8RvYLzRFtfxWzdC1CQHSdWo6kJrDzl