此代码正确执行,并且在终端/cmd/VScode 中的输出很好 [天城文]。但是当我尝试像 demo.py>test.json 一样保存它时,这个 “charmap”编解码器无法对位置 150-153 中的字符进行编码:字符映射到 该文件中存在的错误。
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)
