The construction of lateral p-n junctions is very important and challenging in two-dimensional (2D) semiconductor manufacturing process. Previous researches have demonstrated that vertical p-n junction can be prepared simply by vertical stacking of 2D materials. However, interface pollution and large area scalability are challenges that are difficult to overcome with vertical stacking technology. Constructing 2D lateral p-n homojunction is an effective strategy to address these issues. Spatially selective p-type doping of 2D semiconductors is expected to construct lateral p-n homojunction. In this work, we have developed a low-energy ion implantation system that reduces the implanted energy to 300 eV. Low-energy implantation can form a shallow implantation depth, which is more suitable for modulating the electrical and optical properties of 2D materials. Hence, we utilize low-energy ion implantation to directly dope nitrogen ions into few-layer WS2 and successfully realize a precise regulation for WS2 with its conductivity type transforming from n-type to bipolar or even p-type conduction. Furthermore, the universality of this method is demonstrated by extending it to other 2D semiconductors, including WSe2, SnS2 and MoS2. Based on this method, a lateral WS2 p-n homojunction is fabricated, which exhibits significant rectification characteristics. A photodetector based on p-n junction with photovoltaic effect is also prepared, and the open circuit voltage can reach to 0.39 V. This work provides an effective way for controllable doping of 2D semiconductors.