Facial expression recognition (FER) is widely used in many fields. To further improve the accuracy of FER, this paper proposes a method based on double‐code LBP‐layer spatial‐attention network (DLSANet). The backbone model for the DLSANet is an emotion network (ENet), which is modified with a double‐code LBP (DLBP) layer and a spatial attention module. The DLBP layer is at the front of the first convolutional layer. More valuable features can be extracted by inputting the image processed by DLBP into convolutional layers. The JAFFE and CK+ datasets are used, which contain seven expressions: happiness, anger, disgust, neutral, fear, sadness, and surprise. The average of fivefold cross‐validation shows that DLSANet achieves a recognition accuracy of 93.81% and 98.68% on the JAFFE and CK+ datasets. The experiment reveals that the DLSANet can produce better classification results than state‐of‐the‐art methods.