I am a newbie to Python. I am fetching sensor readings and it has too many decimal places (x.xxxxxxxx
)
I want to limit the reading into 4 decimals places (x.xxxx
).
from altimu10v5.lsm6ds33 import LSM6DS33
from altimu10v5.lis3mdl import LIS3MDL
from altimu10v5.lps25h import LPS25H
from time import sleep
lsm6ds33 = LSM6DS33()
lsm6ds33.enable()
lps25h = LPS25H()
lps25h.enable()
lis3mdl = LIS3MDL()
lis3mdl.enable()
while True:
#print(lsm6ds33.get_accelerometer_raw())
print("{:.2f}".format.lsm6ds33.get_accelerometer_g_forces())
sleep(0.4)
When I run this code I get the following error message:
" attribute error : ' builtin_function_or_method' object has no attribute 'lsm6ds33'
答案 0 :(得分:2)