-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.py
104 lines (32 loc) · 1.14 KB
/
file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import os.path
import time
import sys
# 这个文件实现文件打开,判断文件大小功能
class Fileor():
def __init__(self,path):
self.path = path
def file_walk(self):
size = 0
for dirn,r2,fname in os.walk(self.path):
for i in fname:
size += os.path.getsize(dirn +"//"+ i)
return dirn,fname,size
def otfile(self):
#返回值依次为书名,格式,文件完整路径
st = []
mt = []
completepath = []
path,filelist,file_size_sum = Fileor.file_walk(self)
if file_size_sum >= 25000000:
print("所选择文件总大小不得大于25M\n")
print("请关闭该窗口,减少文件数量,以满足要求")
time.sleep(5)
sys.exit()
else:
for i in range(len(filelist)):
strr = filelist[i]
completepath.append(path+"\\"+ strr)
st.append(strr.split(".")[0])
mt.append(strr.split(".")[1])
return st,mt,completepath