To solve the problems of A* algorithm, such as excessive number of redundant nodes, slow search time and sharp turn of path. a new approach is proposed: a five-neighborhood search A* algorithm that incorporates dynamic weighting in the heuristic function and utilizes second-order Bezier curve for path smoothing. Through the simulation environment built by PyCharm, it can be seen that the number of redundant nodes and the search time of the A* algorithm after dynamic weighting of five neighborhoods are reduced by 86.57% and 82.07% compared with the traditional eight-neighborhood search algorithm, and the cost remains the same in the precision of ten thousand bits. the path obtained after Bezier curve processing has no large angle turning points. After smooth optimization, the continuity of speed and acceleration can be maintained during the driving process, and the driving fluency can be improved.