A two-dimensional (2D) conjugated microporous polymer with a structure of 2D nanosheets has been synthesized. Theoretical calculations and experimental results reveal that the Fermi level of this 2D polymer aligns well with perovskite absorber, and its conduction band is high enough to block electron transport into the anode. This 2D polymer is used to modify the hole transport layer, significantly improving its photoelectric properties, including enhanced hole mobility, matched energy level, and reduced recombination. Furthermore, the 2D polymer exhibits a mesoporous structure, allowing perovskite to fill into its loose framework, increasing the hole export area and providing a large hole transport flux. As a result, the efficiency of inverted perovskite solar cells enhances to 24.64 % from 21.17 % of control device without 2D conjugated microporous polymer. Given that this material can be synthesized on a large scale, this work has significant implications for the future development of 2D polymers in perovskite solar cells, potentially accelerating industrialization.