好了,所以我最后讲了我在这里编写的代码,在我的网站上的链接已失效,在
archive.org上查看(也可以在GitHub上查看)。我可以按以下方式使用它:
from filelock import FileLockwith FileLock("myfile.txt.lock"): print("Lock acquired.") with open("myfile.txt"): # work with the file as it is now locked
好了,所以我最后讲了我在这里编写的代码,在我的网站上的链接已失效,在
archive.org上查看(也可以在GitHub上查看)。我可以按以下方式使用它:
from filelock import FileLockwith FileLock("myfile.txt.lock"): print("Lock acquired.") with open("myfile.txt"): # work with the file as it is now locked