On 12/4/17 4:36 AM, Cecil Westerhof wrote:
I have a script that was running perfectly for some time. It uses:
array = [elem for elem in output if 'CPU_TEMP' in elem]
But because output has changed, I have to check for CPU_TEMP at the
beginning of the line. What would be the best way to implement this?
No need for a regex just yet:
array = [elem for elem in output if elem.startswith('CPU_TEMP')]
(btw, note that the result of this expression is a list, not an array,
for future Googling.)
--Ned.
--
https://mail.python.org/mailman/listinfo/python-list