We obtain characterizations of almost periodic and weakly almost periodic functions on an arbitrary locally compact Hausdorff group. They include in particular some results of Loomis giving sufficient conditions for a function on an Abelian group to be almost periodic.