Objective. To investigate the prevalence of anxiety and depression in hospitalized patients in the Department of Gastroenterology and to explore the risk factors affecting psychosomatic conditions in patients with digestive disorders. Methods. Patients hospitalized with gastrointestinal diseases were enrolled by the Department of Gastroenterology of Xiangya Hospital of Central South University from November 2017 to June 2018 and completed a cross-sectional questionnaire survey. According to anxiety/nonanxiety, depression/nondepression, the subjects were divided into two groups, respectively, and the risk factors of anxiety/depression were analyzed. Results. A total of 1186 patients were included in this study. The overall detection rate was 20.74% for anxiety symptoms alone, 31.78% for depressive symptoms alone, 13.99% for both anxiety and depressive symptoms, and 38.53% for either depression or anxiety symptoms. The prevalence of anxiety symptoms was higher in female than in male patients and inversely correlated with levels of education. There was no significant difference in the detection rate of anxiety and depression between patients with functional and organic digestive diseases. Sleep quality and quality of life were inversely correlated with the severity of anxiety and depression. Notably, among the patients with abnormal psychological conditions, only 7.6% of them were willing to receive psychological treatment. Gender, sleep quality, and life quality are independent risk factors for anxiety and depression symptoms for inpatients with gastrointestinal diseases. Conclusion. Paying more attention to the education level, sleep quality, and quality of life in patients with gastrointestinal diseases will help doctors to identify the risk of psychological abnormalities and improve medical care.