我发现我必须关闭REPORT123.txt文件,但我不确定我是否用了正确的方法
这是我的密码:
if size > 0:
os.rename("C:\\Users\\Desktop\\Folder\\log.txt", 'C:\\Users\\Desktop\\Folder\\REPORT123.txt
path = 'C:\\Users\\Desktop\\Folder\\REPORT123.txt
files = {'file': open(path, 'rb')}
url = 'https://api.pcloud.com/uploadfile'
data = {'username': 'myemail@gmail.com', 'password': 'mypassword'}
r = requests.post(url, files=files, data=data)
print(r.text)
time.sleep(2)
open(path, 'rb').close() #I think that the problem is maybe here
time.sleep(2)
for filename in glob.glob("C:\\Users\\Desktop\\Folder\\REPORT*"):
os.remove(filename)
f = open("log.txt", "a")
else:
print("file is not full ")
问题是:
Traceback (most recent call last):
File "C:/Users/Desktop/Folder/fileupload.py", line 48, in <module>
os.remove(filename)
PermissionError: [WinError 32] the process cannot access the file because it is being used by another process: 'C:\\Users\\Desktop\\Folder\\REPORT123.txt'
目前没有回答
相关问题 更多 >
编程相关推荐