import time
def main(file_name):
try:
with open(file_name, 'r', encoding='utf-8') as f:
lines = f.readlines()
print(lines)
start=time.time()
print('总数:',len(lines))
new_lst=list(set(lines))
print('去重后:',len(new_lst))
print(time.time()-start,'秒')
with open(file_name,'w', encoding='utf-8') as f:
f.write(''.join(new_lst))
print('文件保存到:',file_name)
except Exception as e:
print('错误的文件路径!!!', e)
if __name__ == '__main__':
main('a.txt')