I am reading in a text file (named Untitled.txt) and I am trying to return the text after "make": (so the desired result would be "Lucid", in this case)
Example text:
[{"make":"Lucid","model":"Air (Dream Edition R)",
Python script:
import re
a_string = open('Untitled.txt','r')
makes = re.findall('"make":[a-zA-Z] ', str(a_string))
print(makes)
Output: []
I get no results. Why? How do I fix this??
CodePudding user response:
a_string is file object , you can use it to get content.
such as
a_string = open('Untitled.txt', "r")
r_string = flag.read()
then use re.findall
makes = re.findall('"make":[a-zA-Z] ', r_string)
print(makes)
