This paper presents a weighing method for a truck scale based on a neural network (NN) with penalty function (PFNN). Firstly, the truck scale’s prior knowledge, i.e. the positive partial derivatives of the truck scale’s input–output function and the distributions of truck scale’s permissible weighing errors, is used to construct the constraints for optimizing the NN. Then, the penalty function is applied to construct the new NN’s performance index, and the detailed algorithm for training this NN is given. Finally, the method for assigning the value of the penalty factors is also discussed. The comparative experimental results show that the PFNN’s generalization ability is better than that of a data-induced NN (DINN) especially with a lack of training samples (the DINN is a method for training an NN only by using the data samples, not prior knowledge), and the weighing errors of the truck scale with PFNN are far less than those of DINN. In addition, the convergence of the PFNN is faster than that of the DINN.