[Python] R: Registri modbus

cm a python.it
Ven 18 Feb 2022 14:18:43 CET


Il giorno gio 17 feb 2022 alle ore 17:32 Alessandro T.
<tagliare3 a yahoo.it> ha scritto:
>
> reg = [21070, 12601, 12340, 12593, 12593, 13312]
>
> versione compatta:
> s = ''.join(c for r in reg for i in (1,0) if (c:=chr(r >> 8*i &
> 0xff)).isalnum())

oppure anche

```
>>> "".join(chr(n) for d in reg for n in divmod(d, 256) if n != 0)
'RN190411114'
```

㎝

--
!!!! THE 🍺-WARE LICENSE (Revision ㊷):
    <㎝🐌🐍.🇮🇹> wrote this 📧. As long as you retain this notice you can
    do whatever you want with this stuff. If we meet some day, and you
    think this stuff is worth it, you can buy me a 🍺 in return. — ㎝


Maggiori informazioni sulla lista Python