2024-09-27 00:14:05 发布
网友
我正在使用此代码:newAgent = [random.gauss(0, 1), random.gauss(0, 1)] 我想限制小数后的位数点。现在大约是20位数。在
newAgent = [random.gauss(0, 1), random.gauss(0, 1)]
答案很简单。只需使用round,然后用, #Number of spaces指定位置。在这个例子中,我做了5个小数位。在
round
, #Number of spaces
import random newAgent = [random.gauss(0, 1), random.gauss(0, 1)] print(round(newAgent[0], 5), round(newAgent[1], 5))
答案很简单。只需使用
round
,然后用, #Number of spaces
指定位置。在这个例子中,我做了5个小数位。在相关问题 更多 >
编程相关推荐