I am trying to count the lines in a JSON file. Click HERE to access my JSON file .
I tried to use the below code to count the lines.
input = open(\"
The default UTF-8 encoding of Python 3 only extends to byte->str conversions. open()
instead uses your environment to choose an appropriate encoding:
From the Python 3 docs for open()
:
encoding
is the name of the encoding used to decode or encode the file. This should only be used in text mode. The default encoding is platform dependent (whatever locale.getpreferredencoding() returns), but any text encoding supported by Python can be used. See the codecs module for the list of supported encodings.
In your case, as you're on Windows with a Western Europe/North America, you will be given the 8bit Windows-1252 character set. Setting encoding
to utf-8
overrides this.