I am new to python. I'm confused by the <class 'str'>
.
I got a str by using:
response = urllib.request.urlopen(req).read().decode()
The type of 'response' is <class 'str'>
, not <type 'str'>
.
When I try to manipulate this str in 'for loop':
for ID in response:
The 'response' is read NOT by line, BUT by character.
I intend to put every line of 'response' into individual element of a list. Now I have to write the response in a file and use 'open' to get a string of <type 'str'>
that I can use in 'for loop'.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…