Besides its promising high electron mobilities at room temperature, PtSe2 has a finite bandgap sensitively dependent on the number of monolayers combined by the van der Waals interaction according to our calculations based on the density functional theory. It was found that the frontier orbitals of the valence band maximum and the conduction band minimum are mainly contributed by pz and px+y orbitals of Se, which are sensitive to the out-of-plane and the in-plane lattice constants, respectively. The van der Waals force enhances the bonding out-of-plane, which in turn influences the bonding in-plane. We explain that the layer number dependent bandgap has the same electronic reason as the strain dependent bandgap based on the scenario above. This work shows the flexibilities of tuning the electronic and optical properties of PtSe2 in a wide range, which provides an advantage for applications of PtSe2 in sensors.