Terahertz spectra of four kinds of representative explosives are measured by terahertz time-domain spectroscopy in both nitrogen and air environment. Using the methods of average smoothing, Fourier low-pass filtering and wavelet decomposition and reconstruction, the oscillations on the spectra caused by the water vapor absorption are removed. The experimental results indicate that the terahertz spectra of the explosive materials have distinct features, which can be used as the standards for recognition, and the study of eliminating the influence of water vapor makes the technique of detecting explosives by terahertz time-domain spectroscopy take a step toward practicality.