国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

恢復百度云盤本地誤刪的文件腳本(簡單方法)

2020-02-16 10:27:33
字體:
來源:轉載
供稿:網友

今天被同步盤搞得焦頭爛額。

辛苦碼的代碼(除了重要的、備份過的)都被刪掉了……

當時我就石化了。。。

隨后發現同步盤目錄有個delete目錄,里面還有manifest.xml,和一堆改了名的文件,

看到manifest.xml的內容時,瞬間覺得有救了,立馬開搞python

廢話不多說,直接上代碼:

#-*- coding:utf-8 -*-from xml.etree import ElementTreeimport osimport sysreload(sys)sys.setdefaultencoding( "utf-8" )def convertfile(cachePath,orgPath): '''恢復文件''' start=0; while True:  index = orgPath.find('//', start)  if index == -1:   break  start = index + 1 orgDir=orgPath[:start] print 'orgDir:',orgDir if not os.path.exists(orgDir):   os.makedirs(orgDir)  if not os.path.exists(orgPath) or(os.path.exists(orgPath) and (os.path.getsize(orgPath) != os.path.getsize(cachePath))):   file_in=open(cachePath, "rb")  file_out=open(orgPath, "wb")  file_out.write(file_in.read())   file_in.close()  file_out.close()  def read_xml(text): '''讀xml文件''' root = ElementTree.fromstring(text)  lst_node = root.getiterator("record") for node in lst_node:  cp=node.attrib['cachePath']  op=node.attrib['orgPath']  cp=cp.replace('~','.')  op=op.replace('~','.')  print cp+'->'+op  convertfile(cp,op) if __name__ == '__main__': '''將本文件放在云同步盤的根目錄下,  將mani_file改為需要恢復的manifest文件''' mani_file=".//.baohe.cache//.delete//20140412//manifest.xml" read_xml(open(mani_file).read())

本文件在Python2.7.6下正常,3.4貌似有問題(汗)

python可以在官網下載:https://www.python.org/downloads/

將本文件(假如叫做huifu.py)放在云同步盤的根目錄下,比如云同步盤在“d:/baiduyun/”,那么文件應該在“d:/baiduyun/”下,最終是這樣的“d:/baiduyun/huifu.py”

千萬不要輕易從百度云上刪除已經上傳的文件??!血淚教訓。。。

以上這篇恢復百度云盤本地誤刪的文件腳本(簡單方法)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鲁山县| 淄博市| 凤阳县| 集贤县| 灯塔市| 汉源县| 青岛市| 田阳县| 温泉县| 嘉兴市| 石棉县| 尉氏县| 阳朔县| 璧山县| 东源县| 西充县| 衡阳市| 微山县| 南郑县| 会同县| 鄯善县| 高青县| 洪雅县| 日喀则市| 茶陵县| 龙胜| 晋城| 星子县| 平昌县| 庆城县| 阿拉善左旗| 固原市| 大余县| 巴里| 萍乡市| 梁山县| 湖口县| 湖口县| 密山市| 栾城县| 靖边县|