發表文章

目前顯示的是 3月, 2023的文章

陳映年python字典dictionaries

圖片
w3scholls練習程式碼 #字典 key:values, 陳映年 #w3schools原來 字串:字串,改成 整數:字串 a = { #市場價值最大的五家公司 2330: "台積電", 2317: "鴻海", 2454: "連科發", 2412: "中華電", 6505: "台塑化" } print(a) print(a[6505]) print(a.get(2330))#功能同 a[2330] print(a.keys()) #keys()方法列出所有key搜尋鍵 b = a.copy() print("列出b " + str(b)) print(b[2317]) print(b.clear()) a.update({2308: "台達電"}) print(a.values()) print("用迴圈列出字典a的所有值") for t in a: print(a[t]) print(a.values()) #keys()方法列出所有values值 字典方法dictionaries Python has a set of built-in methods that you can use on dictionaries. Method Description clear() Removes all the elements from the dictionary copy() Returns a copy of the dictionary fromkeys() Returns a dictionary with the specified keys and value get() Returns the value of the specified key items() Returns a list containing a tuple for each key value pair keys() Returns a list containing the dictionary's keys pop() Removes the elem

陳映年SVG與 CANVAS

圖片
w3schools練習SVG w3schools練習CANVAS 心得 <svg>svg程式碼</svg> <canvas>canvas程式碼</canvas> <script>網頁JavaScript程式碼</script> ol是order list順序清單, gt大於, lt小於前面加上&控制 教學影片 維基百科Canvas element 維基百科SVG

陳映年w3schools字串str, format, slicing[::]

圖片
w3schools 程式碼 #陳映年strings可以用單引雙引只要對稱 b = '123,456,789' # 0 1 23 4 5 678 9 10,11,12 print('字串長度' + str(len(b))) #len函數 字串長度 輸出 整數 #str函數 轉成字串 這樣才能串接 print(b[-5:-2]) #練習字串格式format quantity = "日k" itemno = 3 price = "朋友" myorder = "我要去 {} 唱幾小時 {} 和 {} 一起唱" print(myorder.format(quantity, itemno, price)) 心得: 這次的課程蠻有趣的。