Reading least significant bits in Python

前端 未结 4 1349
忘掉有多难
忘掉有多难 2021-01-20 07:59

I am having to parse the Facility and Severity of syslog messages in Python. These values come with each message as a single integer. The severity of the event is 0-7, spe

4条回答
  •  既然无缘
    2021-01-20 08:11

    The normal way to extract the least significant bits would be to do a bitwise AND with the appropriate mask (7 in this case)

提交回复
热议问题