python - 如何解决“[Winerror]:10054 现有连接被远程主机强行关闭”?
问题描述
我正在尝试使用 VirusTotal API 获取 json 响应。为了获取结果作为响应,我创建了一个 python 脚本,如下所示: 然后错误显示如下: [Winerror]:10054 现有连接被远程主机强行关闭
import requests
url = "https://www.virustotal.com/vtapi/v2/file/scan"
api_key = "MyApiKey"
params = {"apikey": api_key}
files = {"file": ("app.exe", open("C:/Users/Administrator/Desktop/malware detection/app.exe", "rb")}
try:
response = requests.post(url, files=files, params=params)
print(response.json())
except Exception as e:
print(e)
解决方案
要提供更多信息,请尝试以下操作:
import requests
url = "https://www.virustotal.com/vtapi/v2/file/scan"
api_key = "MyApiKey"
params = {"apikey": api_key}
files = {"file": ("app.exe", open("C:/Users/Administrator/Desktop/malware detection/app.exe", "rb"))}
try:
response = requests.post(url, files=files, params=params)
print(response.json())
except Exception as e:
print(e)
并发布您从更新代码中收到的错误响应。
推荐阅读
- java - “线程“主”java.util.MissingFormatArgumentException 中的异常:格式说明符“%.4f””
- java - 如何使用 Java 将 Arduino 代码写入 Arduino
- python - 使用 Python 函数将字符串传递给 pymysql 游标
- spreadsheet - 如何通过 App 脚本将松弛消息添加到谷歌电子表格
- java - 可变对象的 Java“按值传递”含义
- angular - 如何在 Angular 中获取 Angular Material 元素的值?
- python - 我可以一次运行多个 Python 脚本吗?
- flutter - 在 Flutter 中,我可以把 FutureBuilder
在定时器里面? - python - 如何获取一列中的价格数据并按年份将其分成不同的列?
- mongodb - 如果在 Rust 中使用 skip_serialize serde 属性,则无法将字段写入 MongoDB 文档