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

前端 未结 10 755
抹茶落季
抹茶落季 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:35

    If someone looking for these, this is an example for converting a CSV file in Python 3:

    try:
        inputReader = csv.reader(open(argv[1], encoding='ISO-8859-1'), delimiter=',',quotechar='"')
    except IOError:
        pass
    

提交回复
热议问题