Photon-Counting-Detector (PCD) has a broad application prospect in medical X-ray computed tomography (CT) and Xray (XR) imaging, which can improve contrast and spatial resolution, optimize spectral imaging, and use energy-dependent attenuation coefficient for the great potential of material composition identification. However, the measurement provided by the photon-counting-detector causes spectral distortion due to physical phenomena such as pulse pileup effect, charge sharing, K-escape and Compton scattering occurring in the detector. Since the calculation of the physical phenomenon that causes distortion is very complicated, this paper proposes a method of using the neural network for spectral correction based on Monte Carlo simulation, that is, using the Monte Carlo method to simulate the particle transport process to obtain undistorted spectrum as the label of the neural network, the spectrum is used as the input data of the neural network, and the relationship between the distortion spectrum and the corrected spectrum is learned by training the neural network. After the training is completed, using the test set for model evaluation, the standard error between the predicted result and the label was only 25.1601ppm. This method can effectively correct the spectral distortion problem of the photon-countingdetector, and can more accurately invert the X-ray spectral data.