“for line in…” results in UnicodeDecodeError: 'utf-8' codec can't decode byte

前端 未结 10 864
抹茶落季
抹茶落季 2020-11-22 17:15

Here is my code,

for line in open(\'u.item\'):
#read each line

whenever I run this code it gives the following error:



        
10条回答
  •  天命终不由人
    2020-11-22 17:38

    Also worked for me, ISO 8859-1 is going to save a lot, hahaha, mainly if using Speech Recognition API's

    Example:

    file = open('../Resources/' + filename, 'r', encoding="ISO-8859-1");
    

提交回复
热议问题