The ionospheric total electron content (TEC) is an important parameter to describe the ionosphere. However, the study of TEC modeling mainly focuses on the calm period of the layer, and its application in the period of magnetic storms is relatively rare. To solve this problem, this paper uses LSTM, BiLSTM, CNN-LSTM-Attention and CNN-BiLSTM-Attention neural network models to train various spatio-temporal data of magnetic storm periods from 2002 to 2022, and obtains four TEC prediction models suitable for magnetic storm periods. Then, the accuracy and reliability of the four prediction models were verified by the measured TEC of two magnetic storms in 2023. The results showed that the CNN-BiLSTM-Attention model was significantly prior to the other three models in predicting the magnetic storm period, and the root mean square error (RMSE) was between 4.732 and 10.45 TECu. At the same time, there is a strong correlation with the reference value, the coefficient of determination (R
2) is between 0.682 and 0.949, and the slope of the fitting function is closest to 1.