I want to take the first line of a file opened from an url, search for a specific string and then split that string.
request=urllib.request.Request(url)
response=urllib.request.urlopen(request)
input_file=response.readlines()
for l in input_file:
if "target" in l:
dum, stat = l.split(":")
stat = stat.strip()
I expect to get a stat="StationX" instead I get
TypeError: a bytes-like object is required, not 'str'
because input_file is a list of type bytes instead of type strings. I don't know how to either bring input_file in as strings (I thought thats what readlines() vs read() did?) or convert the list of type bytes to a list of type stings.