The water vapor noise will affect the accuracy of the extracted optical parameters based on terahertz time domain spectroscopy technology. Because vapor noise has the characteristics of wide distribution and high intensity, the existing denoising methods cannot be effectively applied to the THz signal with vapor noise. In this paper, a numerical denoising method is presented. First, based on Van Vleck-Weisskopf lineshape function and the linear absorption spectrum of water molecules in the HITRAN database, we have simulated the water vapor absorption spectrum with line width, and the continuum effect of water vapor molecules are considered in the simulation. Then, the transfer function of different humidity is constructed by the calculation of the water vapor absorption coefficient and the real refractive index; Finally, based on the propagation factor formula of the mutual effects of THz wave and water vapor, the THz signal of the Lacidipine sample containing vapor noise in the continuous frequency domain of 0.3-1.8THz is denoised by using the constructed transfer function of the water vapor; the optical parameters of the sample signal before and after denoising can be extracted. It can be seen that the optical parameters extracted from the denoised signal are close to the optical parameters in the nitrogen environment, which proves the effectiveness of denoising. Under low humidity, this method can still accurately extract the optical parameters of samples without nitrogen filling, which saves the cost, enhances the convenience of the application of terahertz time domain spectroscopy in pharmaceutical production, safety inspection, imaging etc.