Remove Duplicates from Text File

前端 未结 7 1053
梦毁少年i
梦毁少年i 2020-12-17 05:34

I want to remove duplicate word from a text file.

i have some text file which contain such like following:

None_None

ConfigHandler_56663624
ConfigHa         


        
相关标签:
7条回答
  • 2020-12-17 06:11
    import json
    myfile = json.load(open('yourfile', 'r'))
    uniq = set()
    for p in myfile:
    if p in uniq:
        print "duplicate : " + p
        del p
    else:
        uniq.add(p)
    print uniq
    
    0 讨论(0)
提交回复
热议问题