defgetNonRepeatList1(data):returnlist(set(data))defgetNonRepeatList2(data):
new_data =[]for i inrange(len(data)):if data[i]notin new_data:
new_data.append(data[i])return new_data
#多维数组适用,作用与最外层defgetNonRepeatList3(data):return[i for n, i inenumerate(data)if i notin data[:n]]defgetNonRepeatList4(data):print(dict.fromkeys(data))returnlist(dict.fromkeys(data))defgetNonRepeatList5(data):import pandas as pd
return pd.unique(data).tolist()
input_list =[1,1,2,4,6,7,4,2]print(getNonRepeatList1(input_list))print(getNonRepeatList2(input_list))print(getNonRepeatList3(input_list))print(getNonRepeatList4(input_list))print(getNonRepeatList5(input_list))