'Python, typeerror about string and bytes
I used Youtube API and got list of comments. And trying to change it into single string so I can use konlpy.
a = str(' '.join(c)).encode("UTF-8")
But I got
"TypeError: sequence item 0: expected str instance, bytes found"
So I tried
a = str(b' '.join(c)).encode("UTF-8")
It pops
"TypeError: sequence item 0: expected a bytes-like object, str found"
What is the problem?
+) Input c is...
response = api_obj.commentThreads().list(part='snippet,replies', videoId=viedoIdd, maxResults=100).execute()
while response:
for item in response['items']:
comment = item['snippet']['topLevelComment']['snippet']
comments.append([comment['textDisplay']])
for c in comments:
a = str(' '.join(c)).encode("UTF-8")
words.append(a)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
