-1
我想我的Python 2的代碼轉換成Python3,但我收到以下錯誤:不能Concat的字節STR(轉換到Python3)
Traceback (most recent call last):
File "markovtest.py", line 73, in <module>
get_all_tweets("quit_cryan")
File "markovtest.py", line 41, in get_all_tweets
outtweets = [(tweet.text.encode("utf-8") + str(b" ")) for tweet in alltweets]
File "markovtest.py", line 41, in <listcomp>
outtweets = [(tweet.text.encode("utf-8") + str(b" ")) for tweet in alltweets]
TypeError: can't concat bytes to str
的問題是在這個for循環:
outtweets = [(tweet.text.encode("utf-8") + " ") for tweet in alltweets]
我試過改變編碼來完全解碼或刪除編碼參數,但我無法弄清楚。任何幫助,將不勝感激。
您是在代碼上運行2to3還是什麼,因爲回溯代碼與您顯示的源代碼不匹配。 – Blckknght