if not my_bytearray:
print("Read drop out")
should work fine.
The mistake in your code is that you compare a bytearray to a string; that is always False
. if my_bytearray == b"":
would have worked. But the solution above tends to be more Pythonic and more used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.