Wie muss das Programm (siehe Anhang) geändert werden, so dass es unter
Python 3 läuft?
Unter Python 2 werden Temperatur und Feuchtigkeit angezeigt:
1 | 23.1205371094
|
2 | 40.4630126953
|
Unter Python 3 kommt eine Fehlermeldung:
1 | Traceback (most recent call last):
|
2 | File "HTU21D.py", line 100, in <module>
|
3 | obj = HTU21D()
|
4 | File "HTU21D.py", line 43, in __init__
|
5 | self.dev.write(CMD_SOFT_RESET) #soft reset
|
6 | File "HTU21D.py", line 31, in write
|
7 | self.fw.write(bytes)
|
8 | TypeError: a bytes-like object is required, not 'str'
|