The precision of short-term photovoltaic power forecasts is of utmost importance for the planning and operation of the electrical grid system. To enhance the precision of short-term output power prediction in photovoltaic systems, this paper proposes a method integrating K-means clustering: an improved snake optimization algorithm with a convolutional neural network–bidirectional long short-term memory network to predict short-term photovoltaic power. Firstly, K-means clustering is utilized to categorize weather scenarios into three categories: sunny, cloudy, and rainy. The Pearson correlation coefficient method is then utilized to determine the inputs of the model. Secondly, the snake optimization algorithm is improved by introducing Tent chaotic mapping, lens imaging backward learning, and an optimal individual adaptive perturbation strategy to enhance its optimization ability. Then, the multi-strategy improved snake optimization algorithm is employed to optimize the parameters of the convolutional neural network–bidirectional long short-term memory network model, thereby augmenting the predictive precision of the model. Finally, the model established in this paper is utilized to forecast photovoltaic power in diverse weather scenarios. The simulation findings indicate that the regression coefficients of this method can reach 0.99216, 0.95772, and 0.93163 on sunny, cloudy, and rainy days, which has better prediction precision and adaptability under various weather conditions.