Find Unique Characters in a File

前端 未结 22 2343
耶瑟儿~
耶瑟儿~ 2021-02-04 03:30

I have a file with 450,000+ rows of entries. Each entry is about 7 characters in length. What I want to know is the unique characters of this file.

For instance, if my f

22条回答
  •  名媛妹妹
    2021-02-04 04:24

    s=open("text.txt","r").read()
    l= len(s)
    unique ={}
    for i in range(l):
     if unique.has_key(s[i]):
      unique[s[i]]=unique[s[i]]+1
     else:
      unique[s[i]]=1
    print unique
    

提交回复
热议问题