The invention discloses a knowledge base construction method and device oriented to a program design field question-answering system. The method comprises the following steps that: according to the knowledge contents of an online evaluation system, preliminarily establishing an intelligent question-answering knowledge base; obtaining a user question, carrying out sentence word segmentation on thequestion, carrying out synonym replacement, and carrying out similarity calculation with contents in the knowledge base; if a user is satisfied with a current returning answer, according to question answering, synchronously updating an intelligent question-answering knowledge base, and applying a code similarity algorithm to detect data in a cache in real time; and otherwise, returning a suboptimum answer to the user until the user is satisfied. By use of the system, the problems in a traditional online after class question answering system that a time difference is in the presence, search accuracy is low, efficiency needs to be improved and the like, the information acquisition speed and accuracy of the user can be effectively improved, and meanwhile, the teaching effect of the online evaluation system is optimized.