The basic equations of the thermodynamic system give the relationship between the internal energy, entropy and volume of two neighboring equilibrium states. By using the functional relationship between the state parameters in the basic equation, we give the differential equation satisfied by the entropy of spacetime. We can obtain the expression of the entropy by solving the differential equationy. This expression is the sum of entropy corresponding to the two event horizons and the interaction term. The interaction term is a function of the ratio of the locations of the black hole horizon and the cosmological horizon. The entropic force, which is strikingly similar to the Lennard-Jones force between particles, varies with the ratio of the two event horizons. The discovery of this phenomenon makes us realize that the entropic force between the two horizons may be one of the candidates to promote the expansion of the universe.