Last active
February 26, 2020 12:30
-
-
Save e96031413/a6e76d13e7f1e75afdaf4fdae8d36501 to your computer and use it in GitHub Desktop.
A short note on Python List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python list usage | |
list1.append() # 加到最後面 | |
list1.insert(0,var) # 加到指定位置 | |
list1.extend(list2) # 將list2合併到list1 | |
list1.remove("C") # 移除list1中的"C" | |
list1.pop(0) # 刪除第0個項目 | |
list1.pop() # 刪除最後1個項目 | |
list1.clear() # 清空list1 | |
list1.count() # 計算有多少項目 | |
list1.index(x) # 找出x在第幾個項目 | |
list1.reverse() # 由後往前排列list1 | |
list1.copy() # 複製list1到新的listName | |
list1[:] # 顯示整個清單 | |
list1[:-1] # 顯示整個清單,但不含最後一個元素 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment