Background: The widespread transmission of human papillomavirus (HPV) in women poses significant health risks. The objective of this study is to elucidate the prevalence characteristics of preoperative and postoperative HPV infection in patients with cervical intraepithelial neoplasia (CIN) and cervical cancer. Methods: A total of 370 patients diagnosed with CIN or cervical cancer were recruited in the study. Initially, we analysed the overall prevalence of HPV infection in preoperative patients, as well as the characteristics within different age groups and various pathological diagnoses. Subsequently, we examined the correlation between HPV positive rates and age, pathological diagnoses, HPV genotypes and multiple HPV infection in postoperative patients. Finally, we conducted a comparative analysis of HPV infection dynamics in the same cohort of patients before and after cervical operation. Results: The overall HPV positive rate was 97.02% among patients diagnosed with CIN or cervical cancer. The top six prevalent HPV genotypes identified were as follows: HPV16, HPV52, HPV58, HPV33, HPV51, and HPV18. Patients displayed varying distributions of HPV infection across different age groups and pathological diagnoses. Notably, the proportions of HPV16, HPV51, and multiple HPV infection differed significantly among patients of different ages. The proportions of HPV16, HPV18, HPV51, HPV52, and multiple HPV infection were significantly different among patients with distinct cervical lesions. Among the 282 patients who underwent cervical operation, 113 individuals (40.07%) remained positive for HPV postoperatively. Patients agedā„60 years, with CINI cervical lesion, preoperative positivity for HPV51 and multiple HPV infection, exhibited a higher postoperative rate of HPV positivity. Additionally, the positive rate of the top six prevalent HPV genotypes except for HPV51 and multiple HPV infection showed a declining trend after cervical operation. Conclusions: This study further substantiated the link between high-risk HPV infection and the development of CIN and cervical cancer, and also offered insights for the prevention and treatment of postoperative HPV infection.