the regular expression is not working. please find the below details.
cpu_pattern = re.compile('.*CPU.*(usr|user).*nice.*sys.*')
part = b'11:40:24 AM CPU %usr %nice %sys %iowait %steal %irq %soft %guest %idle\n11:40:25 AM all 0.00 0.00 0.08 0.00 0.00 0.00 0.00 0.00 99.92'
IF condition:
if cpu_pattern.search(part): if cpu_usage == '': cpu_usage == part
Error:
TypeError('cannot use a string pattern on a bytes-like object')