The stellar occultation technique is capable of atmospheric trace gas detection using the molecule absorption characteristics of the stellar spectra. In this paper, the non-iterative and iterative retrieval methods for oxygen and air density detection by stellar occultation are investigated. For the single-band average transmission data in the oxygen 761 nm A-band, an onion-peeling algorithm is used to calculate the effective optical depth of each atmospheric layer, and then the optical depth is used to retrieve the oxygen number density. The iteration method introduces atmospheric hydrostatic equilibrium and the ideal gas equation of state, and it achieves a more accurate retrieval of the air density under the condition of a priori temperature deviation. Finally, this paper analyzes the double solution problem in the iteration process and the ideas to improve the problem. This paper provides a theoretical basis for the development of a new type of atmospheric density detection method.