国产探花免费观看_亚洲丰满少妇自慰呻吟_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”

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

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 孟津县| 靖边县| 太和县| 无极县| 荣成市| 德庆县| 郁南县| 南京市| 灵川县| 尼玛县| 嵊州市| 融水| 横山县| 区。| 淳安县| 四平市| 衢州市| 包头市| 历史| 措勤县| 西充县| 庐江县| 中卫市| 贵溪市| 彝良县| 南昌县| 达日县| 张家川| 商南县| 邢台县| 兴国县| 蓬安县| 大悟县| 合阳县| 囊谦县| 岑溪市| 同江市| 旬邑县| 东平县| 仁布县| 辽宁省|