Используйте наборы в Python.Допустим, вы хотите найти уникальные символы в файле url.txt
f=open('url.txt')
a=''
for x in f:
x=x.split(' ')
for y in x:
a+=y
unique=set(a)-set('@!#.') #add the characters that you wanna neglect in the second set
print(unique)
print('unique characters : ',len(unique))
Допустим, url.txt содержит:
Google --! google.com --! coolest search engine
facebook --! facebook.com --! biggest social network
yahoo --! yahoo.com --! biggest web portal
вывод будет:
{'a', 'G', 'm', '\n', 'n', 'c', 'b', 'e', 'g', 'f', 'i', 'h', 'k', '-', 'l', 'o', 'p', 's', 'r', 't', 'w', 'y'}
unique characters : 22