Output is good in CMD and vscode but not in text/json file [python][Devanagari]

115 Views Asked by At

This code executes properly and output in terminal/cmd/VScode is good [Devanagari]. but when I try to save it like demo.py>test.json this 'charmap' codec can't encode characters in position 150-153: character maps to error present in that file.

enter image description here

import requests

headers = {
  'Accept-Encoding': 'gzip, deflate',
  'User-Agent': 'okhttp/5.0.0-alpha.2'
    }
i = "680"
url = "https://example.com/get/demo_id?id="+str(i)

try:
    response = requests.request("GET", url, headers=headers) 
    print(response.text)
except Exception as e: print(e)
0

There are 0 best solutions below