The present invention relates to a new pyrrole sulfonyl derivative, and a preparation method and medical use thereof. In particular, the present invention relates to a pyrrole sulfonyl derivative as represented by general formula (I), a preparation method thereof, a pharmaceutical composition comprising the derivative, and a use thereof as a therapeutic agent, in particular as a gastric acid secretion inhibitor and as potassium-competitive acid blockers (P-CABs), wherein each substituent group of general formula (I) is the same as that defined in the description.