擅长:python、mysql、java
<p>以下是操作系统不可知的版本:</p>
<pre><code>try:
file = open("thefile.txt", "r+")
except IOError:
print "File is open!"
</code></pre>
<p>编辑以添加您的问题是<a href="https://stackoverflow.com/questions/6825994/check-if-a-file-is-open-in-python">check if a file is open in Python</a>的副本</p>