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
Here is a simple solution using sets to remove the duplicates from the text file.
lines = open('workfile.txt', 'r').readlines() lines_set = set(lines) out = open('workfile.txt', 'w') for line in lines_set: out.write(line)