We first deduce a uniform formula forthe Fermi energy of degenerate and relativistic electrons in the weak-magnetic field approximation. Then we obtain an expression of the special solution for the electron Fermi energy through this formula, and express the electron Fermi energy as a function of electron fraction and matter density. Our method is universally suitable for relativistic electron- matter regions in neutron stars in the weak-magnetic field approximation.