可以使用set()函數(shù)來去除重復數(shù)據(jù),set()函數(shù)會返回一個只包含不重復元素的集合。例如,有一個包含重復元素的列表,可以使用set()函數(shù)來去除重復元素:
data = [1, 2, 3, 3, 4, 4, 5] unique_data = list(set(data)) print(unique_data)
輸出結(jié)果為:
[1, 2, 3, 4, 5]
億速云公眾號
手機網(wǎng)站二維碼
Copyright ? Yisu Cloud Ltd. All Rights Reserved. 2018 版權所有
廣州億速云計算有限公司粵ICP備17096448號-1 粵公網(wǎng)安備 44010402001142號增值電信業(yè)務經(jīng)營許可證編號:B1-20181529