I have a byte in varibale 'DATA'. I want to extract the LSB bit out of it and print it. I'm very new to python, I found many articles with complex bitwise addition logic and all which was very tough to understand. I'm looking for a simple logic like we do with the strings eg DATA[7:1] Please help me out...
相关问题
- Django __str__ returned non-string (type NoneType)
- How to postpone/defer the evaluation of f-strings?
- Extract P-Values from Dunnett Test into a Table by
- ImportError shows up with py.test, but not when ru
- Comparing pd.Series and getting, what appears to b
相关文章
- Airflow depends_on_past explanation
- Raspberry Pi-Python: Install Pandas on Python 3.5.
- Numpy array to TFrecord
- How to split a DataFrame in pandas in predefined p
- Error following env.render() for OpenAI
- AttributeError: 'Series' object has no att
- ImportError: cannot import name 'joblib' f
- How to save a file downloaded from requests to ano
Right shift by the number n and take the last bit by and 1
Is your "byte" an
int
? If so, just take bitwise AND (&
) with1
(or, if you want to be more explicit, the binary literal0b1
) to get the least significant bit.Is your "byte" a
bytes
object? If so, just index into it and take bitwise AND.