The best way is a technique called "probing". This isn't something you should attempt yourself. A veterinarian that specializes in reptiles will be able to do this for you.
Snakes can be sexed by "popping" when hatchlings, or probing as an adult. Only an experienced breeder should attempt to sex a snake because of the risk of damage.