我试图移动一个图像后,打开它在一个api中发布为多部分。
import requests
import shutil
data = {...}
image = r"D:\some\file\path\image.png"
with open(image, 'rb') as image_:
response = requests.post(
"https://somesite.com",
timeout=60,
data=data,
files={
"file": image_,
})
if response.status_code == 201:
shutil.move(image, r"D:\some\file\new_path\image.png")
我犯了个错误
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process:
我已尝试通过以下方式关闭文件:
image_.close()
但不起作用。
暂无答案!
目前还没有任何答案,快来回答吧!