The invention relates to a spectrum sensing-based single-path service partitioning-merging spectrum allocation method in an elastic optical network. An algorithm consists of two parts, when a new service arrives, a spectrum availability-based service-divisible spectrum allocation method is used to allocate spectrum resources for the service, n spectrum blocks with the largest total residual frequency availability of links of a path that the service passes in occupation are selected to transmit the service, the residual spectrum availability of the links is maximized as much as possible, and the blocking rate of a network is reduced; and when an old service leaves, bandwidth resources are released, a spectrum availability-based service merging method is used, whether idle spectrum blocks large enough to satisfy a bandwidth requirement of service merging exist in the path that services under transmission in a partitioned manner pass is inquired, and spectrum availability of links is not reduced after merging, and if the bandwidth requirement is satisfied, the services are merged. The spectrum sensing-based single-path service partitioning-merging spectrum allocation method aims to reduce spectrum resource waste caused by service splitting and too much use of an equipment port, further reduce the blocking rate of the network, and save energy consumption of the equipment port.