The invention provides a preparation method of a molecular imprint ratio fluorescence sensor for detecting hepatitis B virus. In the present invention, a metal-organic framework material (MIL-101) is used as an imprinting carrier, a virus aptamer is modified on its surface, a fluorescent dye monomer rhodamine B and a template virus are added for imprinting, and an aptamer is obtained after the template is eluted. Molecularly imprinted polymer with dual recognition of molecularly imprinted cavity. After the imprinted polymer was combined with the target, the fluorescence intensity of the fluorescent dye Rhodamine B changed while the fluorescence of MIL-101 was almost unchanged. Based on this, a ratiometric fluorescence detection system was constructed. The method combines the advantages of metal organic framework materials, molecular imprinting technology and fluorescence ratiometric detection, high detection sensitivity, low detection limit, good selectivity, low background signal, and imprinting factor up to 5.72, which has a good application prospect in virus detection. .