簡體   English   中英

如何恢復被os.remove python中的function刪除的文件?

[英]How to restore files that are deleted by os.remove function in python?

我只是在寫一個 python 代碼來刪除超過 30 天的文件。 在運行它時,不幸的是,我給出了錯誤的路徑,並且我的一些寶貴數據被刪除了。

你能告訴我如何恢復這些數據嗎?

這是我用的function

def remove_file(path):

    # removing the file
    if not os.remove(path):

        # success message
        print(f"{path} is removed successfully")

    else:

        # failure message
        print(f"Unable to delete the {path}")

有 python 模塊允許安全刪除,如“send2trash”。 然后,您可以從回收站或垃圾箱中恢復文件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM