Although minor alloying in metallic glasses (MGs) has been extensively investigated, the effect of O doping is still a debatable topic. In the present study, the atomic-level structures and mechanical properties of Zr-based MGs doped with different O contents have been analyzed using ab initio molecular dynamics simulations. It is revealed that O atoms prefer to bond to Zr atoms due to their low mixing enthalpy, and that O atoms degrade the properties of Zr-lean MGs but hardly affect the properties of Zr-rich MGs, with results suggesting a compositional dependence of O doping. For Zr-lean MGs, the fraction of full icosahedra, size of the medium-range-order clusters, Young's modulus and shear modulus decrease sharply with O content, while accompanied by a sharp increase of the non-Frank-Kasper polyhedra, and the ratio of bulk modulus to shear modulus and Poisson's ratio, indicating decreased strength and improved plasticity. For Zr-rich MGs, however, the above-mentioned structural and mechanical features experience little change or only change slightly after O doping, showing low oxygen sensitivity. It is shown that the high Zr content weakens the effect of Zr-O bonding to some extent. The present study not only sheds light on the atomic-level structures of O-doped MGs, which may provide guidelines for designing MGs with low-grade materials, but also helps to explain the previous conflicting results based on the composition-dependence effect.