[Solved] Python – Read string from log file

[ad_1]

Can be extracted with a simple regular expression, as long as the text file is in the same format as the Python log output you posted (Returns all of them):

import re
file="".join([i for i in open("yourfileinthesamefolder.txt")])
serials=re.findall("u'serial_number': u'(.+)'",file)
print(serials)

I suggest reading up on how to use regular expressions in Python:

Regular Expression HOWTO — Python 3.7.2 documentation

[ad_2]

solved Python – Read string from log file