-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileforTest.py
More file actions
42 lines (35 loc) · 882 Bytes
/
fileforTest.py
File metadata and controls
42 lines (35 loc) · 882 Bytes
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
36
37
38
39
40
41
42
# !/usr/bin/python
import os
def main():
def dirList(path):
fileList = os.listdir(path)
fpath = os.getcwd()
allfile = []
for filename in fileList:
filepath = os.path.join(fpath, filename)
if os.path.isdir(filepath):
dirList(filepath)
allfile.append(filepath)
return allfile
list = dirList('D:/workspace/python/')
print(list)
filename = input("please input fileName:")
try:
fop = open(filename)
except IOError:
print("NameError")
except NameError:
print("内部出错!")
# finally:
# if fop:
# fop.close()
# else:
# pass
finally:
try:
fop.close()
except NameError:
pass
print("fop not found!")
if __name__ == '__main__':
main()