The embodiments of the present application relate to the technical field of encoding and decoding, and disclose an encoding method, a decoding method, a corresponding device, an electronic device, and a storage medium, wherein the encoding method includes: determining a block to be encoded according to all quantization coefficients of the block to be encoded Identification information, the identification information is a first identification or a second identification, the first identification is used to identify that all quantized coefficients of the block to be encoded are non-zero coefficients, and the second identification is used to identify that there are zero coefficients in all quantized coefficients of the block to be encoded Then determine the context of the identification information, and encode the identification information according to the context of the identification information; If the identification information is the first identification, then the value level of each quantization coefficient of the coding block is to be encoded; If the identification information is the second identification , the run and level of each non-zero coefficient of the block to be coded are coded. With the method provided by the embodiment of the present application, the code stream can be effectively saved.