1. 程式人生 > >Python: 用+號就能把兩個數組合並!

Python: 用+號就能把兩個數組合並!

python新手,今天才知道用+號就能合併兩個陣列:

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

這在以前學c和java的時候,簡直不能想象。內個這麼設計python的人實在太“懶”了!大笑不過這才是我們想要的語言!