-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_case_test.py
More file actions
28 lines (28 loc) · 1.1 KB
/
demo_case_test.py
File metadata and controls
28 lines (28 loc) · 1.1 KB
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
#列出指定目录下的所有py文件
import os
path = os.getcwd() #获取当前的工作目录
print(path)
lst = os.listdir(path)
for filename in lst:
if filename.endswith('.py'):
print(filename)
#path_ch = os.path.join(path,'package')
#print('当前工作目录为:',path_ch)
lst_files = os.walk('../') #获取指定目录下的迭代体对象,元组类型,[(路径,文件夹,文件名)]
for dirpath,dirname,filename in lst_files:
# print(dirpath)
# print(dirname)
# print(filename)
# print('-----------------------------------------------------------------------------------------')
for dir in dirname:
print(os.path.join(dirpath,dir))
for file in filename:
print(os.path.join(dirpath,file))
print('-----------------------------------------------------------------------------------------')
lst_t = [('Jack',20,'lol'),('Jam',32,'Music'),('Mare',43,'ball')]
for i,j,k in lst_t:
print(i)
print(j)
print(k)
print('-----------------------------------------------------------------------------------------')
print('\\')