The invention belongs to the technical field of data-driven water flow forecasting, and discloses a flood forecasting method based on a time sequence attention mechanism, which comprises the following steps of: firstly, collecting hydrological data of studied medium and small watersheds, and then inputting the collected hydrological historical data into a model after data preprocessing; secondly, performing data cleaning, data conversion, data set division and the like on the hydrological historical data; thirdly, constructing a flood forecasting model based on a time sequence attention mechanism; inputting test data to test the performance of the forecasting model, judging whether the network performance meets requirements or not, and if not, adjusting parameters until an ideal forecasting result is achieved; and finally, analyzing the model through an evaluation standard, and completing flood forecasting. The method has the beneficial effects that the flood peak precision and the flood trend can be effectively forecasted, and the method is an effective tool for forecasting the flood of medium and small rivers in real time.