With the rapid development of information technology, artificial intelligence technology gradually penetrates the field of education, providing new possibilities for the innovation of teaching mode. The traditional teaching mode often has problems such as single teaching resources, low student participation and insufficient cultivation of practical ability. To solve these problems, this paper proposes a practical teaching mode based on the concept of Human-Machine collaboration. It aims to harness the advantages of human and machine and improve teaching efficiency and quality. Taking the course “Python and Web Crawler” as an example, a teaching framework includes four modules: knowledge learning, practical training, evaluation feedback and personalized tutoring. An AI-assisted teaching system integrating the functions of knowledge base, adaptive learning, automatic evaluation, virtual practice and teacher assistance is also developed. The application of this model in practical teaching shows that the Human-Machine collaborative teaching model is effective. According to the experimental results of this research, firstly, the average learning time of students this semester has decreased by about 20% compared to the previous semester, but the average score of the final grade has improved by about 5%. Secondly, the students’ project works are better than in the previous semester in terms of code quality and functional completion, especially the improvement in code quality is the most obvious. Finally, based on ten questions, the overall evaluation of the students on the course this semester is significantly higher than that of the last semester. Therefore, we firmly believe that this research provides a useful exploration for the application of AI in education.