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

首頁 > 編程 > Python > 正文

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

2020-01-04 16:37:52
字體:
來源:轉載
供稿:網(wǎng)友

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

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

當時我就石化了。。。

隨后發(fā)現(xiàn)同步盤目錄有個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可以在官網(wǎng)下載:https://www.python.org/downloads/

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

千萬不要輕易從百度云上刪除已經(jīng)上傳的文件啊!血淚教訓。。。

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

 

注:相關教程知識閱讀請移步到python教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 红桥区| 钦州市| 滁州市| 万山特区| 木兰县| 太仆寺旗| 延长县| 龙口市| 筠连县| 新民市| 西华县| 扎兰屯市| 那坡县| 舞阳县| 定边县| 望都县| 安达市| 宁国市| 柏乡县| 黔南| 棋牌| 仁怀市| 安丘市| 常宁市| 赤峰市| 阿坝| 远安县| 沈阳市| 桓台县| 都兰县| 宁化县| 肇东市| 涟水县| 蒲城县| 桂平市| 高密市| 响水县| 大宁县| 梓潼县| 蚌埠市| 西青区|