How to check whether a file is_open and the open_status in python

前端 未结 4 536
暗喜
暗喜 2021-01-12 07:39

Is there any python functions such as:

filename = \"a.txt\"
if is_open(filename) and open_status(filename)==\'w\':
   print filename,\" is open for writing\"         


        
4条回答
  •  攒了一身酷
    2021-01-12 08:24

    I don't think there is an easy way to do what you want, but a start could be to redefine open() and add your own managing code. That said, why do you want to do that?

提交回复
热议问题