当我运行python脚本时,有时会收到以下错误:
”进程无法访问该文件,因为该文件正在被 另一个过程”
现在,我想知道:python中是否有办法:
<form id="select-file">
<input type="file" name="receipt_front" id="receipt_front" class="inputfile" required>
<label class="file" for="receipt_front"><span>Select file</span></label>
<div id="receipt_front_file_name"></div>
...
...
</form>
$("#select-file").validate({
rules: {
receipt_front: {
required: true
}
},
messages: {
receipt_front: {
required: "field required"
}
},
errorPlacement: function (error, element) {
return false;
},
submitHandler: function (form) {
alert('form submitted');
}
});
)感谢您的帮助。
答案 0 :(得分:1)
如果您与psutil匹配所需的文件,则可以尝试遍历进程并杀死它:
import psutil
for p in psutil.process_iter():
try:
if "filename" in str(p.open_files()):
print(p.name())
print("^^^^^^^^^^^^^^^^^")
p.kill()
except:
continue