title: UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 7738: character maps to <undefined>
body: <p>I'm trying to get a Python  program to extract a date from a website and copy this data to a json file. here is the part of the code which concerns the creation of the json file :</p>
  <pre><code>with open(city+'.json', 'w', encoding='utf8') as file:
          json.dump(data, file ,ensure_ascii=False)
  
  with open('citys.txt', &quot;r&quot;) as file:
          citys = file.readlines()
  </code></pre>
  <p>When i try to execute the code I get the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main3.py&quot;, line 173, in &lt;module&gt;
  get_data_from_company(company_link['href'],city_name_id[0])
    File &quot;main3.py&quot;, line 132, in get_data_from_company
  data = json.load(file)
    File &quot;C:\Python38\lib\json\__init__.py&quot;, line 293, in load
  return loads(fp.read(),
    File &quot;C:\Python38\lib\encodings\cp1252.py&quot;, line 23, in decode
  return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 7738: character maps to &lt;undefined&gt;
  </code></pre>