A computer-implemented codon optimization method for the expression sequence of a protein based on an immune algorithm, wherein the codon optimization method comprises the following three steps: a first step of local optimization, that is, cleaving the protein sequence into nonoverlapping sequence fragments A 1, A 2...A n, and then using the immune algorithm to complete the codon optimization for each sequence fragment, so as to generate an approximately optimal DNA sequence set B 1, B 2...B n; a second step of global optimization, that is, initializing the DNA coding sequence of the full length of the protein based on B 1, B 2...B n utilizing a genetic algorithm, and screening out the optimal DNA sequence C 1 of the protein sequence; and a third step of fine adjustment and optimization, which comprises performing exhaustive optimization on the 5' terminal of the DNA sequence corresponding to the N-terminal region of the encoded protein to generate a DNA sequence C 2, and eliminating an expression inhibitory motif, to finally generate the optimal expression sequence D of the protein; wherein the immune genetic algorithm adopts a multi-objective optimization method to perform local optimization on the protein fragments, the population initialization is based on a duplex codon table of a sequence encoding a highly-expressed protein, and each gene is directly encoded by synonymous codons; and in the optimization process, antibody diversity is ensured and the phenomenon of population degeneration is prevented by calculating antibody information entropy, antibody population similarity, antibody concentration and polymerization fitness of the immune genetic algorithm and updating memory cells, so as to increase the global search capability of the algorithm; wherein the genetic algorithm adopts the multi-objective optimization method to perform global optimization on the full sequence of the protein, an initialized population is randomly generated based on optimized fragments subjected to local optimization, and each gene is directly encoded by an optimized sequence set of each protein fragment; wherein the fine adjustment and optimization uses the exhaustive method to calculate and sort the minimum free energy MFE, Codon Context and CAI at the 5' terminal of the DNA sequence, and selects the optimum coding sequence for the N-terminal of the protein sequence according to the sorting result. wherein the codon optimization method comprises the following three steps: a first step of local optimization, that is, cleaving the protein sequence into nonoverlapping sequence fragments A 1, A 2...A n, and then using the immune algorithm to complete the codon optimization for each sequence fragment, so as to generate an approximately optimal DNA sequence set B 1, B 2...B n; a second step of global optimization, that is, initializing the DNA coding sequence of the full length of the protein based on B 1, B 2...B n utilizing a genetic algorithm, and screening out the optimal DNA sequence C 1 of the protein sequence; and a third step of fine adjustment and optimization, which comprises performing exhaustive optimization on the 5' terminal of the DNA sequence corresponding to the N-terminal region of the encoded protein to generate a DNA sequence C 2, and eliminating an expression inhibitory motif, to finally generate the optimal expression sequence D of the protein; wherein the immune genetic algorithm adopts a multi-objective optimization method to perform local optimization on the protein fragments, the population initialization is based on a duplex codon table of a sequence encoding a highly-expressed protein, and each gene is directly encoded by synonymous codons; and in the optimization process, antibody diversity is ensured and the phenomenon of population degeneration is prevented by calculating antibody information entropy, antibody population similarity, antibody concentration and polymerization fitness of the immune genetic algorithm and updating memory cells, so as to increase the global search capability of the algorithm; wherein the genetic algorithm adopts the multi-objective optimization method to perform global optimization on the full sequence of the protein, an initialized population is randomly generated based on optimized fragments subjected to local optimization, and each gene is directly encoded by an optimized sequence set of each protein fragment; wherein the fine adjustment and optimization uses the exhaustive method to calculate and sort the minimum free energy MFE, Codon Context and CAI at the 5' terminal of the DNA sequence, and selects the optimum coding sequence for the N-terminal of the protein sequence according to the sorting result.