|
发表于 2020-4-5 00:12:04
|
显示全部楼层
- # 输入盘名-->显示盘下面的所有目录
- # 选择目录下的文件夹-->显示文件夹下的所有目录并显示地址
- import os
- import win32api,win32con
- def showfile(path):
- num = 1
- all_file = os.listdir(path) # listdir(path='.')# 列举指定目录中的文件名('.'表示当前目录,'..'表示上一级目录)#os.curdir指代当前目录('.')
- for each_file in all_file:
- if bool(win32api.GetFileAttributes(each_file) & win32con.FILE_ATTRIBUTE_HIDDEN):
- continue #获取文件或目录是否有隐藏属性,有则continue
- print('%s.%s' % (num, each_file))
- num += 1
- def montage():
- temp_path = input('请输入地址:【C/D/E/F】:') + ':\\'
- TEMP_PATH = temp_path.upper()
- if TEMP_PATH not in ['C:\\','D:\\',' E:\\', 'F:\\']:
- input('您的输入有误,请重新输入地址:【C/D/E/F】:') + ':\\'
- return
- else:
- showfile(temp_path)
- montage()
复制代码 |
|