The invention discloses a photoelectrochemical aptamer sensor and a preparation method and application thereof. The sensor comprises a working electrode, the reaction end face of which is modified with a composite film, wherein the composite film is composed of a graphite phase carbon nitride nanosheet composite material jointly modified by gold nanoparticles/cerium dioxide quantum dots; and a specific aptamer probe is self-assembled on the surface of the composite film. The preparation method comprises the following steps: modification of CeO2QDs/Au/g-C3N4 and fixation of the specific aptamer probe. The photoelectrochemical aptamer sensor disclosed by the invention has the advantages of high stability, long service life, strong anti-interference capability, wide detection range, low detection limit and the like, can realize specific detection of target objects in media such as water bodies and organisms, and is high in utilization rate, high in use value and good in application prospect. The preparation method of the sensor has the advantages of simple process, convenience in operation, safety, low cost, no pollution, high manufacturing efficiency and the like, is suitable for large-scale preparation and is beneficial to industrial application.