Python元組、列表、集合及列表去重操作
1.元組、列表、集合
元組(tuple)
小括號、可以有相同元素、不可改只能讀
列表(list)
中括號、可以有相同元素、可以進行增刪改查
集合(set)
大括號、不存放相同元素
2.列表去重操作
對列表進行去重操作1:
#coding = utf-8 a = [11,22,33,11,22,33] b = [] for i in a: if i not in b: b.append(i) print("去重操作前:") print(a) print("去重操作後:") print(b) 執行結果: |
對列表進行去重操作2:
a = [11,22,33,11,22,33] print(a) b = set(a) print(b) c = list(b) print(c) 執行結果: |
相關文章
- Python 列表、元組、字典及集合操作詳解Python
- python_列表——元組——字典——集合Python
- python列表元組的操作Python
- python元組和列表Python
- Python列表、元組、字典使用Python
- Python的元組和列表Python
- Python 入門學習 -----變數及基礎型別(元組,列表,字典,集合)Python變數型別
- Python 學習之元組列表Python
- python list列表基礎(元組)Python
- Python之列表&元組小練Python
- python基礎之元組,列表Python
- python list(列表)和tuple(元組)Python
- Python3組合資料型別(元組、列表、集合、字典)語法Python資料型別
- Python對列表去重的4種方法Python
- python資料型別 列表+元組Python資料型別
- python 元組,列表 迴圈遍歷Python
- Python第六週列表與元組Python
- 【Python_029】內建資料結構,列表 | 字典 | 集合 | 元組Python資料結構
- Python中幾種資料結構的整理,列表、字典、元組、集合Python資料結構
- Python列表及元組的相同點與不同點介紹Python
- Python3之字串str、列表list、元組tuple的切片操作Python字串
- Python中列表去重常用的3種方法!Python
- python如何返回元組,列表或字典的?Python
- python列表(list)和元組(tuple)詳解Python
- python基礎之列表list元組tuplePython
- python元組、列表的異同總結Python
- Python列表、元組、集合、字典的區別是什麼?入門知識!Python
- 【美妙的Python之五】變數:列表、元組、元字典Python變數
- Python基礎——while、字串、列表及操作PythonWhile字串
- Python中列表、元組、字典、集合與字串,相關函式,持續更新中……Python字串函式
- Python學習筆記8——列表、字典、元組Python筆記
- Python中的元組和列表的區別Python
- python自學第三天(-)-列表、元組、字典Python
- 總結python 元組和列表的區別Python
- 列表及相關操作
- Python 元組,不可變的列表,滾雪球學 PythonPython
- Python列表切片操作Python
- 微課|玩轉Python輕鬆過二級(2.1.4節):列表、元組、字典、集合概述Python