中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Python文件的一些操作代碼

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用
#! /usr/bin/python
# -*- coding:utf-8 -*-
'''
Created on 2013-12-11

@author: Java
'''
import os
import MySQLdb
from db.DbUtil import DbUtil
class FileOption():
def __init__(self):
pass

def CreateFloderByList(self,pathList):
'''
創(chuàng)建文件夾
:param pathList:文件夾集合
'''
self.pathList = pathList
for path in pathList:
if not os.path.isdir(path):
os.makedirs(path)

def CreateFloder(self,path):

self.path = path
if not os.path.isdir(path):
os.makedirs(path)

def readFileName(self,path):
fileNames = os.listdir(path)
return fileNames


def copyFiles(self,sourceDir, targetDir):

for file in os.listdir(sourceDir):
sourceFile = os.path.join(sourceDir, file)
targetFile = os.path.join(targetDir, file)
if os.path.isfile(sourceFile):
if not os.path.exists(targetDir):
os.makedirs(targetDir)
if not os.path.exists(targetFile) or(os.path.exists(targetFile) and (os.path.getsize(targetFile) != os.path.getsize(sourceFile))):
open(targetFile, "wb").write(open(sourceFile, "rb").read())
if os.path.isdir(sourceFile):
First_Directory = False
create = FileOption()
create.copyFiles(sourceFile, targetFile)

def moveFiles(self,dir):
'''根據(jù)文件名創(chuàng)建文件夾,并將其放入對應(yīng)的文件夾內(nèi)'''
for i in os.listdir(dir):
name = ''.join(i.split('.html')[0:-1])
print name
os.mkdir(os.path.join(dir,name))
os.rename(os.path.join(dir,i), os.path.join(dir,name,i)) 

標(biāo)簽: Mysql

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:使用FileUpload上傳文件的主要Java代碼

下一篇:百度與谷歌地圖坐標(biāo)轉(zhuǎn)換代碼