An efficient molecularly-imprinted electrochemical sensor for the detection of ampicillin was prepared using polypyrrole tetracycline polymer modified with ZrO2 nanofibers. The ZrO2 nanofibers prepared by electrostatic spinning increased the surface area of the electrode with the binding sites of the electropolymerized membrane. The ampicillin sensor with polypyrrole as the functional monomer was able to specifically bind ampicillin molecules and detect ampicillin in various types of samples. In this study, cyclic voltammetry and differential pulse voltammetry were used to evaluate the electrochemical performance of ZrO2-MIP. Under the optimized conditions, the detection limit of this sensor was 0.397 nM, the detection range was 0.5 ∼ 500 nM, and the R2 reached 0.998. It has good selectivity, reproducibility, and stability, and achieves the AMP detection of the milk of the actual samples, which has a good prospect of application.