Localization of sensor nodes is the foundation of the entire wireless sensor network. The article introduces the localization process of sensor nodes of DV-HOP algorithm. Based on this, it proposes an improved DV-HOP algorithm which based on weighted least square method. The new algorithm introduced a weighted method related with hops to differentiate the anchor node influence, and proposed a new method of determining location of the node. The simulation results show that the proposed improvements can greatly enhance the localization accuracy of the nodes.