The invention relates to the field of molecular virology and immunology, and particularly, relates to a gene sequence for encoding a human papillomavirus 31 type L1 protein and with a termination codon of TAG, and an encoded protein and a preparation method thereof, and virus-like particles containing the encoded protein the protein and the virus-like particles can be used for preventing HPV (especially HPV31) infection and diseases such as cervical cancer and the like caused by the HPV (especially HPV31) infection. The invention also relates to an application of the protein and the virus-like particles in preparation of a pharmaceutical composition or a vaccine. The pharmaceutical composition or the vaccine is used for preventing the HPV (especially HPV31) infection and the diseases such as cervical cancer and the like caused by the HPV (especially HPV31) infection.