1. 程式人生 > >python將兩個數組合並成一個數組的兩種方法的代碼

python將兩個數組合並成一個數組的兩種方法的代碼

end orange sse 關於 使用 數組 操作 方法 希望

內容過程中,把寫內容過程中常用的內容收藏起來,下面的資料是關於python將兩個數組合並成一個數組的兩種方法的內容,希望能對小夥伴們有幫助。
c1 = ["Red","Green","Blue"]
c2 = ["Orange","Yellow","Indigo"]
c1.extend(c2)

assert c1 == ["Red","Green","Blue","Orange","Yellow","Indigo"]





下面使用+號操作符



c1 = ["Red","Green","Blue"]
c2 = ["Orange","Yellow","Indigo"]
c3 = c1 + c2

assert c3 == ["Red","Green","Blue","Orange","Yellow","Indigo"]




python將兩個數組合並成一個數組的兩種方法的代碼