Considering that karst caves, underground rivers, and dissolution fractures in shallow carbonate formation in the Sichuan Basin are extremely developed, leakage, failure and plugging difficulties are easy to occur in the drilling process. The TDEM was used to carry out the exploration of hidden karst geological bodies in well QM2, and the quasi-three-dimensional inversion based on lateral constrain was used to invert the TDEM data. Three NW trending anomalous bands were identified in the lower Triassic Jialingjiang Formation within the range of drilling, consisting of seven relatively low-resistivity anomalous zones. Under the guidance of TDEM quasi-three-dimensional inversion resistivity data, the low-resistivity karst development area is avoided, and the specific drilling location of well QM2 is determined. No karst cave and underground river were drilled in the later drilling process of well QM2, as well as no instability phenomenon occurred. It indicates that the TDEM detection results are consistent with the actual drilling, and the quasi-three-dimensional TDEM inversion interpretation data based on lateral constraints is reliable and can accurately detect the buried karst in the wellsite.