import numpy
a = numpy.array([[1,2,3,4],[5,6,7,8],[9,8,7,6]])
print(“2D Array: \n”,a)
print(“提取2D array的一部分: \n”,a[1:,2:])
“””
a[1:,2:]
1: , 2:
:之後,沒有指定終止index,
表示含最後一個元素都算
若有指定終止index
終止index的元素不算
“””
![Python提取2D array的一部份資料; import numpy; a[1: , 2:] ; a[1:-1 , 2:-1] - 儲蓄保險王](https://savingking.com.tw/wp-content/uploads/2022/09/20220906112909_96.png)
以下有指定終止元素的index
(-1是最後一個元素的index)
提取就不含終止元素:
![Python提取2D array的一部份資料; import numpy; a[1: , 2:] ; a[1:-1 , 2:-1] - 儲蓄保險王](https://savingking.com.tw/wp-content/uploads/2022/09/20220906122145_65.png)
row有指定終止元素的index
col無指定終止元素的index:
![Python提取2D array的一部份資料; import numpy; a[1: , 2:] ; a[1:-1 , 2:-1] - 儲蓄保險王](https://savingking.com.tw/wp-content/uploads/2022/09/20220906122441_97.png)
list原本就是這樣指定範圍
list[startIdx:endIdx:step]
startIdx未指定則從0開始
endIdx未指定則到最後一個元素(含)
step未指定則為1
現在2D Array一樣意思
[ [list1] , [list2] ]



![Python如何串接OpenAI /Claude /Gemini API自動將大量維修紀錄JSON轉自然語言描述(並避免中斷資料遺失)response = client.chat.completions.create() ; reply = response.choices[0].message.content Python如何串接OpenAI /Claude /Gemini API自動將大量維修紀錄JSON轉自然語言描述(並避免中斷資料遺失)response = client.chat.completions.create() ; reply = response.choices[0].message.content](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/07/20250716084059_0_c5b368.png?quality=90&zoom=2&ssl=1&resize=350%2C233)




![Python爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件) Python爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/03/20250330190318_0_925655.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言