Python - How to check if a file is used by another application?

前端 未结 3 687
面向向阳花
面向向阳花 2020-12-03 12:24

I want to open a file which is periodically written to by another application. This application cannot be modified. I\'d therefore like to only open the file when I know it

3条回答
  •  死守一世寂寞
    2020-12-03 13:08

    One thing I've done is have python very temporarily rename the file. If we're able to rename it, then no other process is using it. I only tested this on Windows.

提交回复
热议问题