I need huffman code(best in python or in java), which could encode text not by one character (a = 10, b = 11), but by two (ab = 11, ag = 10). Is it possible and if yes, where could i find it, maybe it's somewhere in the internet and i just can'd find it?
Huffman code doesn't care about characters, it cares about symbols.  Generally, it is used to encode the alphabet / other single characters, but can very easily be generalized to encode strings of characters.  Basically, you would just take an existing implementation and allow symbols to be strings rather than characters.  A leaf node would then correspond to a list of strings.
Huffman coding two characters as one