The invention belongs to the scientific field of carbon nano-materials and relates to an electrochemical method for preparing petroleum coke-based carbon quantum dots and doping nitrogen in a one-step manner. In the invention, petroleum coke, which has high carbon content, low ash and a developed graphite lamellar structure, is creatively selected as a carbon source, and through an electrochemical oxidizing method, a novel technical method of preparing the carbon quantum dots is developed. Through change on calcination temperature, types of electrolytes and current density, fluorescent performance of the carbon quantum dots can be regulated. By means of addition of a nitrogen-doping agent to the electrolyte, preparation of nitrogen-doped carbon quantum dots through the electrochemical method in one step is achieved, and for the first time, ethylenediamine is employed as the electrolytic nitrogen-doping agent. Meanwhile, for the first time, foam nickel is creatively employed instead of a conventional Pt electrode, so that the method greatly increases electrolytic efficiency and reduces preparation cost. The petroleum coke is easy to obtain and low in cost. The whole process is simple in operation process, is convenient to product the carbon quantum dots industrially in large scale. The carbon quantum dots have wide application prospects in the fields of photo-catalysis, bio-imaging, and detection of ions and macromolecules.