State of charge (SOC) of lithium-ion batteries is an indispensable performance indicator in a battery management system (BMS), which is essential to ensure the safe operation of the battery and avoid potential hazards. However, SOC cannot be directly measured by sensors or tools. In order to accurately estimate the SOC, this paper proposes a convolutional neural network based on self-attention mechanism. First, the one-dimensional convolution is introduced to extract features from battery voltage, current, and temperature data. Then, the self-attention mechanism can reduce the dependence on external information and well capture the internal correlation of features extracted by the convolutional layer. Finally, the proposed method is validated on four dynamic driving conditions at five temperatures and compared with the other two deep learning methods. The experimental results show that the proposed method has good accuracy and robustness.