def remove_duplicates_dev_info (origin_data) :
|
"""对写入设备信息表的数据去重
|
|
Args:
|
origin_data (list): 爬取的原始数据
|
|
Returns:
|
list: 已去除重复的数据
|
"""
|
has_removed_dup_dev_info=[]
|
for item in origin_data :
|
if item[1:4] not in ( [x[1:4] for x in has_removed_dup_dev_info] ) :
|
has_removed_dup_dev_info.append(item)
|
return has_removed_dup_dev_info
|
|
|
|
|
|
|
|
|
|
|
def remove_given_data_dev_info (wait_for_remove_list, sub_data ) :
|
"""wait_for_remove_list的元素[1:4]中包含sub_data,则删除该元素
|
|
Args:
|
wait_for_remove_list (list): 原始列表,元素依然为list类型
|
sub_data (list): 指定子列表
|
|
Returns:
|
temp: 删除后的数据
|
"""
|
|
temp = []
|
for item in wait_for_remove_list :
|
if item[1:4] != sub_data :
|
temp.append(item)
|
return temp
|
|
|
|
|
|
|
|
|
|
# list_test1=['32','衡智远科技(深圳)有限公司', '馨远美食小镇(哈尼美食广场)','hengzhiyuan_64480047078091','']
|
# list_test2=['f','衡智远科技(深圳)有限公司', '馨远美食小镇(哈尼美食广场)','hengzhiyuan_64480047078091','']
|
# list_test3=['gf','衡智远科技(深圳)有限公司', '馨远美食小镇(哈尼美食广场)','hengzhiyuan_64480047078091','']
|
# list_test4=['ds','衡智远科技(深圳)有限公司', '馨远美食小镇(哈尼美食广场)','hengzhiyuan_64480047078091','']
|
# list_test5=['a','衡智远科技(深圳)有限公司', '馨远美食小镇(哈尼美食广场)','hengzhiyuan_64480047078091','']
|
# list_test6=['df','衡智远科技(深圳)有限公司', '馨远美食小镇(哈尼美食广场)','hengzhiyuan_64480047078091','']
|
|
# list_all=[]
|
# list_all.append(list_test1)
|
# list_all.append(list_test2)
|
# list_all.append(list_test3)
|
# list_all.append(list_test4)
|
# list_all.append(list_test5)
|
# list_all.append(list_test6)
|
|
|
# print(remove_duplicates_dev_info(list_all))
|