The interface is crucial for perovskite solar cells (PSCs). However, voids at interfaces induced by the trapped hygroscopic dimethyl sulfoxide (DMSO) can reduce charge extraction and accelerate the film degradation, seriously damaging the efficiency and stability. In this work, 4,4′-dinonyl-2,2′-dipyridine (DN-DP), a Lewis base with long alkyl chains is introduced to solve this problem. Theoretical calculated and experimental results confirm that the dipyridyl group on DN-DP can more strongly coordinate with Pb2+ than that of the S=O group on DMSO. The strong coordination effect plays a crucial role in removing the DMSO-based adduct and reducing the formation of voids. Due to the electron-donating properties of pyridine, the existence of DN-DP in the perovskite film can passivate the defects and optimize the energy level alignment of the perovskite configuration. The open-circuit voltage (VOC) of the DN-DP-based PSC is improved from 1.107 V (control device) to 1.153 V, giving rise to a power conversion efficiency (PCE) of 24.02%. Furthermore, benefiting from the moisture resistance stemming from the hydrophobic nonyl group, the PCE retains 90.4% of the initial performance after 1000 h of storage in the ambient condition.