Sodium-ion batteries (SIBs) and potassium-ion batteries (PIBs) are envisioned as desirable candidates for the realization of future battery systems due to the advantages of their high energy and high power density. However, the construction of anode materials with excellent performance remains a challenge. Herein, few-layered molybdenum sulfide selenide (MoS x Se 2−x ) nanocrystals with a large number of anion defects triggered by both S 2− and Se 2− improve the electrical conductivity and long lifespan of Na + /K + storage. Concurrently, the unique physical confinement with the chemical bonding structure of selenide polyacrylonitrile (SePAN) fibers can mitigate the loss of active material and provide multientry active sites for Na + /K + diffusion. As a result, the MoS 0.25 Se 1.75 -SePAN electrode delivered a superior sodium-storage performance of 521 mAh g −1 for SIBs and 439 mAh g −1 for PIBs at 0.1 A g −1 . Moreover, the long-life cycling performance of the SIBs is remarkable, reaching 391 mAh g −1 over 3600 cycles at 1 A g −1 . In addition, it displays excellent feasibility in a wide working temperature range from −15 to 50 °C for SIBs. This work elucidates a new design for in situ encapsulation and the synergistic function of anion doping and confinement to construct defectrich anodes for high-performance SIBs and PIBs with wide temperature workability.