We report a measurement of the D0 and D+ lifetimes using D0→K−π+ and D+→K−π+π+ decays reconstructed in e+e−→ccˉ data recorded by the Belle II experiment at the SuperKEKB asymmetric-energy e+e− collider. The data, collected at center-of-mass energies at or near the Υ(4S) resonance, correspond to an integrated luminosity of 72fb−1. The results, τ(D0)=410.5±1.1(stat)±0.8(syst.)fs and τ(D+)=1030.4±4.7(stat)±3.1(syst.)fs, are the most precise to date and are consistent with previous determinations.