import os
path = "/Users/home/vien/test"
files= os.listdir(path)
for file in files:
if os.path.isfile(file):
print(file)
import os
def recursive_listdir(path):
files = os.listdir(path)
for file in files:
file_path = os.path.join(path, file)
if os.path.isfile(file_path):
print(file)
elif os.path.isdir(file_path):
recursive_listdir(file_path)
recursive_listdir('/tmp/test')
更多: vien.我爱你
viencoding.com版权所有,允许转载,但转载请注明出处和原文链接: https://viencoding.com/article/74