May-15-2021, 08:59 PM
May-15-2021, 10:29 PM
data_from_the_device = [1663] written_as = data_from_the_device[0] * 0.1 print(written_as)
Output:166.3
May-16-2021, 02:14 AM
Is the data a number, a string, a bytearray, what?
May-16-2021, 04:19 AM
(May-15-2021, 10:29 PM)Yoriz Wrote: [ -> ]It worked, but some values are of the form:data_from_the_device = [1663] written_as = data_from_the_device[0] * 0.1 print(written_as)
Output:166.3
166.3
9.4
21.900000000000002
181.0
47.800000000000004
12.200000000000001
May-16-2021, 04:42 AM
use string formatting
print(f'{written_as:.1f}')or
data_from_the_device = [1663] print(f'{data_from_the_device[0] * 0.1:.1f}')
May-16-2021, 04:48 AM
(May-16-2021, 04:42 AM)buran Wrote: [ -> ]use string formatting
print(f'{written_as:.1f}')or
data_from_the_device = [1663] print(f'{data_from_the_device[0] * 0.1:.1f}')
Everything worked, thank you so much
May-22-2021, 09:24 PM
There was another problem. Now I want to write this data to the database. But how to write correctly:
Now I write like this:
166.3
9.4
21.900000000000002
181.0
47.800000000000004
12.200000000000001
Now I write like this:
cursor.execute(sql, (newHireDate, result1[0] * 0.1, result2[0] * 0.1,result3[0] * 0.1,result4[0] * 0.1,result5[0] * 0.1,result6[0] * 0.1,))But in the database it is written as:
166.3
9.4
21.900000000000002
181.0
47.800000000000004
12.200000000000001