The construction of ideological and political education in the curriculum is an important measure for the high-quality development of higher education in the new era. Physics has a profound historical heritage, a spirit of seeking truth, rigorous scientific thinking and dialectical materialist scientific methods. Therefore, it is particularly important to give full play to the role of physics courses in educating students. This paper takes the Humanistic Physics course offered by pharmaceutical majors as an example, and discusses the teaching objectives and specific measures of ideological and political education as well as the integration of ideological and political elements into practice. It provides a reference for the implementation of ideological and political education in physics courses.