#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: f0rsaken import sys def main(): try: filename = sys.argv[1] except IndexError as e: print(e) sys.exit(2) try: with open(filename, "r") as f: temp_list = f.readlines() except IOError as e: print(e) sys.exit(1) content_list = list() for temp in temp_list: content_list.append(temp.rstrip() + "\n") new_content_list = list() for content in content_list: if content not in new_content_list: new_content_list.append(content) with open("new_" + filename, "w") as f: f.writelines(new_content_list) if __name__ == "__main__": main()
时间: 2024-11-04 16:43:43