The development of high-performance membranes selective for carbon dioxide is critically important for advancing energy-efficient carbon dioxide capture technologies. Although molecular sieves have long been attractive membrane materials, turning them into practical membrane applications has been challenging. Here, we introduce an innovative approach for crafting a polymeric molecular sieve membrane to achieve outstanding carbon dioxide separation performance while upholding the mechanical stability. First, a polymer molecular sieve membrane having high gas permeability and mechanical stability was fabricated from a judiciously designed polymer that is solution-processable, hyper-cross-linkable, and functionalizable. Then, the carbon dioxide selectivity was fine-tuned by the subsequent introduction of various amine-based carriers. Among the diverse amines, polyethyleneimine stands out by functionalizing the larger pore region while preserving ultramicropores, leading to improved carbon dioxide/dinitrogen separation performance. The optimized membrane demonstrates exceptional carbon dioxide/dinitrogen separation performance, outperforming other reported polymer molecular sieve membranes and even competing favorably with most carbon molecular sieve membranes reported to date.