Install a Dictionary Module in Python

696 views python

I want to use all the word in an existing specific Dictionary and create a md5 hash out of it. How will I import a dictionary? What module shall I install?

answered question

1 Answer


Try this with any text file you like..

import hashlib
dict_fn = '/usr/share/dict/american-english'
with open(dict_fn) as f:
    text =
text = text.encode('utf-8')
m = hashlib.md5()

This will give your the same results as md5sum /usr/share/dict/american-english

Note that the dictionary I reference is on Ubuntu and so is the md5sum command line program.

posted this

Have an answer?


Please login first before posting an answer.