The direct current (DC) electric field near the reconnection region has been proposed as an effective mechanism to accelerate protons and electrons in solar flares. A power-law energy spectrum was generally claimed in the simulations of electron acceleration by the reconnection electric field. However in most of the literature, the electric and magnetic fields were chosen independently. In this paper, we perform test-particle simulations of electron acceleration in a reconnecting magnetic field, where both the electric and magnetic fields are adopted from numerical simulations of the MHD equations. It is found that the accelerated electrons present a truncated power-law energy spectrum with an exponential tail at high energies, which is analogous to the case of diffusive shock acceleration. The influences of reconnection parameters on the spectral feature are also investigated, such as the longitudinal and transverse components of the magnetic field and the size of the current sheet. It is suggested that the DC electric field alone might not be able to reproduce the observed single or double power-law distributions.