How to get molecular weight of a compound in python?
7 Answers. from molmass import Formula Formula ('H2O'). >> # monoisotopic mass Formula ('H2O').mass >> # molecular mass. First thing I'd do is replace each occurrence of a letter in the input string by the same letter preceded by a '+', so. next, I'd replace each occurrence of a letter followed by a digit by ...