我是 Python 新手,这周我实际上在上一个短期课程,但我有一个非常具体的要求,我现在不知道如何处理:我在一个文件夹中有许多不同的 txt 文件,当我使用以下代码时,我只收到许多文件中的两个的文件名,这是为什么呢?问候!
import dircache
lista = dircache.listdir('C:\FDF')
i = 0
check = len(lista[0])
temp = []
count = len(lista)
while count != 0:
if len(lista[i]) != check:
temp.append(lista[i- 1])
check = len(lista[i])
else:
i = i + 1
count = count - 1
print (temp)