文件Move操作

#coding=utf-8
import os
import  shutil
stra = "G:/should/v3/a"
strb = "G:/should/v3/b"



fobj = open('D:/V3/bt/c.bt','rb')
line = fobj.readline()
while line:
    #print(line)
    if(line.find('a') > 0):
        line = line.strip('
')
        strsha1 = line.split('\')
        strsha1 = strsha1[-1]
        if(os.path.exists(line)):
            shutil.move(line, stra+'/'+strsha1)
    elif(line.find('b') > 0):
        line = line.strip('
')
        strmd5 = line.split('\')
        strmd5 = strmd5[-1]
        if(os.path.exists(line)):
            shutil.move(line, strb+'/'+strmd5)
    else:
        print(line)

    line = fobj.readline()

fobj.close()

  

原文地址:https://www.cnblogs.com/xiaobaichuangtianxia/p/3804372.html