You must turn them upside down and look at their bums. They will squirm less if they are sitting up rather than flat on their backs. Or get them to go in to one of those clear plastic hamster tubes. You can usally see the testes in the males by 4 weeks of age; this is just after they are ready to leave the mother.
Before that, there are two openings; the male openings are further apart than the female, but unless you are experienced and have handled several different ones you might easily make a mistake.