Air quality is closely related to people’s daily life. In order to predict air quality with high accuracy, the air pollution monitoring data of Lanzhou City from May 13, 2015 to April 18, 2020 is used as the basis, and the LSTM model based on the deep learning library TensorFlow is used to predict the air quality of Lanzhou City and compared with the RNN model. The experimental results show that the mean square error of the model is 39.579212, which is more accurate than the RNN model but takes a longer time, and provides a new prediction method with the scientific and reasonable theoretical basis for air pollution prevention and control work.