python为什么会出现内联浮点打印错误
我在打印时得到一种奇怪的舍入效果。 使用下面的python代码,我试图将所有内容放在一行中。 但是,变量s似乎在第一行中打印错误python为什么会出现内联浮点打印错误,python,floating-point,Python,Floating Point,我在打印时得到一种奇怪的舍入效果。 使用下面的python代码,我试图将所有内容放在一行中。 但是,变量s似乎在第一行中打印错误 s = gb.score(train, y) if (s>0.96)&(s<1.0): print("LR: {0:.3f} estimators: {0:.3f} score: {0:.16f}".format(learning_rate,est,s)) print (s) s=gb.分数(序列,y) 如果(s>0.96)和(s,因
s = gb.score(train, y)
if (s>0.96)&(s<1.0):
print("LR: {0:.3f} estimators: {0:.3f} score: {0:.16f}".format(learning_rate,est,s))
print (s)
s=gb.分数(序列,y)
如果(s>0.96)和(s,因为{0:.16f}
中的0
将插入第一个参数。这就是为什么在这三个位置中,只有学习率的值被插入并格式化
试一试
或者只使用参数的顺序:
print("LR: {:.3f} estimators: {:.3f} score: {:.16f}".format(learning_rate,est,s))
为避免混淆,您还可以使用名称插入:
print("LR: {learningrate:.3f} estimators: {estimators:.3f} score: {score:.16f}".format(learningrate=learning_rate,estimators=est,score=s))
您正在打印learning\u rate
three times learning rate=0.03,estimator=300(我现在也看到了这个错误),我主要关注的是分数
print("LR: {learningrate:.3f} estimators: {estimators:.3f} score: {score:.16f}".format(learningrate=learning_rate,estimators=est,score=s))