The invention is applicable to the technical field of photocatalysis, and provides a method for preparing nickel and nickel carbide modified cadmium sulfide nanowires, which comprises: cadmium chloride and sodium diethyldithiocarbamate trihydrate dissolved in water respectively. The two solutions were mixed, stirred, centrifuged and dried. The dried solid is dissolved in ethylenediamine and then hydrothermally reacted to generate cadmium sulfide. Dissolve cadmium sulfide, nickel nitrate, and hexamethylenetetramine in water. Transfer to a reaction kettle, centrifuge the product, and dry it. Calcined in a tube furnace to obtain nickel and nickel carbide modified cadmium sulfide. The linear cadmium sulfide obtained by the present invention has good dispersion and stable structure; the modified cadmium sulfide obtained by the method of the present invention has a hydrogen production capacity of 15000 μmolg ‑1 h ‑1 , and continued to react for 15 hours, still able to maintain good hydrogen production performance. It can also effectively degrade oxytetracycline (OTC), levofloxacin (LEV), tetracycline hydrochloride (TCH), norfloxacin (NFX), and other antibiotics and dye reactive red 2 (RR2), within 90 minutes, the degradation performance reaches 78 %~91%.