Computational fluid dynamics (CFD) methods, as an efficient tool, have simulated and solved many engineering problems. However, the process is time-consuming and generates numerous underutilized data. Machine learning (ML) provides a way to extract more information from the data and then analyze it for further study. To efficiently handle non-linear problems and analyze numerous data, in this paper, a novel method combining of machine learning and CFD to solve the problems in the field of fluid mechanics is proposed. Two typical algorithms, “the back propagation (BP) algorithm and convolutional neural network (CNN) algorithm”, are chosen to predict the lift and drag coefficients on hydrofoil NACA0012, respectively. The angle of attack (AOA) is considered as a variable. Two different forms are adopted to describe the variable. One is the degree itself and the other is a matrix based on the computational domain in the CFD method. Compared with the target values, the predicted results of both algorithms show great agreement, and the CNN algorithm is more applicable to handle massive data. Furthermore, the cost of time per prediction is about 0.3s, demonstrating great superiority in comparison with that of 147s cost by CFD methods.