centos下mysql中table大小寫改為不敏感
阿新 • • 發佈:2020-11-24
一、列表:
- 列表中可以進行的操作:索引、切片、加、乘、檢查成員。
- 列表是最常用的 Python 資料型別,它可以作為一個方括號內的逗號分隔值出現。
- 列表的資料項不需要具有相同的型別。
- 建立一個列表,只要把逗號分隔的不同的資料項使用方括號括起來即可
示例:
list1 = ['Google', 'Runoob', 1997, 2000] list2 = [1, 2, 3, 4, 5 ] list3 = ["a", "b", "c", "d"] list4 = ['red', 'green', 'blue', 'yellow', 'white', 'black']
二、訪問列表中的值
1、與字串的索引一樣,列表索引從0開始,第二個索引是1,依此類推。
通過索引列表可以進行擷取、組合等操作。
2、索引也可以從尾部開始,最後一個元素的索引為-1,往前一位為-2,以此類推
list = ['red', 'green', 'blue', 'yellow', 'white', 'black'] print( list[0] ) # 輸出:red print( list[1] ) # 輸出:green print( list[2] ) # 輸出:blue print( list[3] ) # 輸出:yellow print( list[4] ) # 輸出:white print( list[5] ) # 輸出:black
print(list[-1]) # 輸出:black
print(list[-2]) # 輸出:white
print(list[-3]) # 輸出:yellow
3、使用下標索引來訪問列表中的值,同樣你也可以使用方括號[]的形式擷取字元,如下所示:
nums = [10, 20, 30, 40, 50, 60, 70, 80, 90] print(nums[0:4]) # 輸出:[10, 20, 30, 40] list = ['Google', 'Runoob', "Zhihu", "Taobao", "Wiki"] # 讀取第二位 print ("list[1]: ", list[1])# 從第二位開始(包含)擷取到倒數第二位(不包含) print ("list[1:-2]: ", list[1:-2]) 輸出: list[1]: Runoob list[1:-2]: ['Runoob', 'Zhihu']