2D Ruddlesden–Popper perovskites have attracted wide attention recently because of tunable optoelectronic properties and have been used as alternatives to their 3D counterparts in various optoelectronic devices. Here, a series of (PEA)2(MA)n−1PbnI3n+1 perovskite thin films is designed and fabricated by a convenient hot‐casting method to obtain gradient n in the films, which leads to the formation of vertical heterojunctions that can enhance charge separation in the films under light illumination. Based on a single gradient perovskite film, a highly sensitive and stable photodetector with a responsivity up to 149 AW−1 and a specific detectivity of 2 × 1012 Jones is obtained. This work paves a way to realizing high‐performance optoelectronic devices with enhanced charge separation by introducing compositional gradient in a perovskite film. [ABSTRACT FROM AUTHOR]