Breastfeeding generates short-term and long-term benefits for both mother and child. Exclusive breastfeeding (EBF) is promoted in China for years, but its practice still lags far behind the international average, even among low- and middle- income countries. This study aimed to investigate factors associated with EBF during postpartum. This study was conducted in a tertiary referral hospital in Gansu Province, Northwest China from October 2019 to April 2020. 3,738 postnatal women were finally included and each of them completed an elaborately designed questionnaire. Infant feeding patterns (EBF or not) and reasons for NEBF (non-exclusive breastfeeding) were collected. The feeding knowledge score was based on 17 questions in relation to breastfeeding. The total score ranges from 0 to 17. Higher score means better understanding about breastfeeding knowledge. Multivariate logistic regression models were used to determine associated factors of EBF during postpartum. A subgroup analysis was conducted to investigate the association between feeding knowledge score and exclusive breastfeeding. Six weeks after childbirth, 1891 mothers (50.6%) maintained EBF. Among the NEBF mothers, 57.01% (n = 1,053) of them stopped exclusive breastfeeding due to self-perceived lack of breast milk production. Factors associated with NEBF were higher maternal age, ethnic minorities and cesarean section. Protective factors of EBF included multipara, positive feeding attitude and high breastfeeding knowledge score. In subgroup analysis, we found the breastfeeding knowledge score had a significant impact on the mothers of Han nationality, underwent cesarean or natural delivery, both primiparous and multiparous, and those with positive attitude towards breastfeeding (p < 0.05). We need a comprehensive and individualized framework of strategies to support children, mothers and their families. During puerperium, improving maternal knowledge of breastfeeding is beneficial to EBF practice. However, for ethnic minorities and those with less active breastfeeding attitudes, breastfeeding knowledge is of limited use, more researches are needed to explore the uncovered reasons, so that more personalized interventions could be developed for them.