简体   繁体   中英

How to open a file with Python on Windows with FileShare permissions?

I have seen this question: How can I read a file even when getting an "in use by another process" exception? Is there an equivalent way to do this using Python on Windows 7?

I need to modify a file but still let other processes read it while it's open in Python. The available modes, according to Python doc are "r","w","a",and "r+", which stand for read, write (overwrite), append, and read/write. I don't see a way to set "FileShare" modes.

If you need fine control over the sharing mode, you can use win32file.CreateFile to open the file. ActiveState docs are here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM