The temperature error caused by the essential loss and the additional loss of Stokes light and anti-Stokes light widely exist in the distributed optical fiber temperature sensor (DTS). According to the temperature demodulation principle of the DTS, a method of fitting the attenuation difference between Stokes light and anti-Stokes light is proposed, which can realize the temperature self-compensation to reduce the temperature measurement error. Two parts at the different positions of the sensing fiber are regarded as the reference section and the temperature measuring section, respectively. The optical signal of the reference section is used as a parameter when demodulating the temperature and fitting the attenuation difference, and the attenuation difference between the Stokes light and the anti-Stokes light is multi-order fitted by the optical signal of the temperature measuring section, then the multi-order fitting results are used to demodulate the temperature for reducing the temperature error caused by the essential loss and additional loss of the Stokes light and anti-Stokes light, in order to implement the preliminary correction of the temperature. Three groups of the different measuring temperature values at the same position of the optical fiber as well as their corresponding signal values are taken in calculation for eliminating the Rayleigh noise, and the relationship of Rayleigh noise with fiber length and temperature are analyzed, and thus further calculating the Rayleigh noise based on the fitting attenuation difference. The influence of the multi-order attenuation difference on the error in temperature measurement and that on the elimination of the Rayleigh noise are compared with each other, and the Rayleigh noise error caused by the essential loss and additional loss of the Stokes light and anti-Stokes light are reduced, then the temperature is corrected again by eliminating the Rayleigh noise. The effect of the multi-order attenuation difference fitting result on the temperature measurement error and on the elimination of Rayleigh noise are analyzed and compared with each other, then the optimal fitting order is obtained. After fitting the additional error at the temperature measurement section that is caused by the additional loss at the reference section, the temperature compensation is carried out by the fitting result, then the final temperature correction is completed. The experimental results show that the temperature correction effect is best by using the first-order linear fitting results in a temperature range of 30-90 ℃, and the temperature measurement error is reduced from 10.50 ℃ to 0.90 ℃ after being corrected three times.