json.load() function give strange 'UnicodeDecodeError: 'ascii' codec can't decode' error

后端 未结 1 748
余生分开走
余生分开走 2021-02-18 16:39

I\'m trying to read a JSON file I have saved in a text file using the python .loads() function. I will later parse the JSON to obtain a specific value.

I keep getting th

1条回答
  •  粉色の甜心
    2021-02-18 17:29

    Specify the encoding in the open call.

    # encoding is a keyword argument
    open("/Users/.../KanyeAllSongs.txt", encoding='utf-8') as data_file:
        data=json.load(data_file)
    

    0 讨论(0)
提交回复
热议问题