ValueError: Precision not allowed in integer format specifier
整数格式说明符中不允许精度,即整数类型的变量不能指定小数点位置,如以下程序示例:
self.logging("best epoch: {:3d}, best f1: {:4.2f}, precision: {:4.2f}, recall: {:4.2f}, total time: {:5.2f}s".format(best_epoch, best_f1_score, best_precision, best_recall, time.time() - init_time))
上述代码中,best_epoch是整数类型,因此best epoch: {:3d}不符合格式要求,可以改为以下程序:
# codes......
self.logging("best epoch: {}, best f1: {:4.2f}, precision: {:4.2f}, recall: {:4.2f}, total time: {:5.2f}s".format(best_epoch, best_f1_score, best_precision, best_recall, time.time() - init_time))