python - 目录中的所有文件未在 python 中显示
问题描述
以下代码是我所拥有的,运行时它显示 1246 个文件,但是当我使用 *. 在驱动器上的搜索文件夹区域中,我看到它们是 5,936 个文件。我怎样才能解决这个问题?谢谢
def walk_error(error):
print(error.filename)
for root, dirs, files in os.walk(r'D:/', onerror=walk_error):
for name in files:
tst2.append(name)
nm.append(name) # Get Name of File
r.append(os.path.join(root, name)) # Get path way of file
created =(os.path.getctime(os.path.join(root, name))) #get creation date of file
p.append(time.ctime(created)) #Add format date of file to list
split_tup = os.path.splitext(os.path.join(root, name)) # Seperate into two tuples
su.append(split_tup) #append tuples to list
file_name = split_tup[0] # Get file name without extension
fn.append(file_name) #Add file name with out extenion to list
file_extension = split_tup[1] # Get file extension
fe.append(file_extension) # Add extension to list
for i in range(1, len(files)):
a = sheet.cell(row=1+i,column =1)
a.value = i
b = sheet.cell(row=1+i,column =2)
b.value = nm[i]
c = sheet.cell(row=1+i, column = 3)
c.value = fe[i]
d = sheet.cell(row=1+i, column = 4)
d.value = p[i]
e = sheet.cell(row=1+i,column =5)
e.value = '=HYPERLINK("{}", "{}")'.format(r[i],'Link to file completed how can I get Created by properties?')
解决方案
推荐阅读
- javascript - 从 ng-bootstrap Modal 删除后用新数据重新加载组件
- c# - NetCore 2.1 TestServer 返回 500 内部服务器错误
- image-processing - 如何使用 scipy.ndimage 找到最大的连接区域?
- java - 如何使用带有 Spring Boot 和 JavaFX 的 Maven 创建一个独立的 jar?
- java - 在 java 中使用 contains() 方法
- ios - 为什么会在没有调用 setActive: 的情况下激活自动布局约束?
- php - PHP TCPDF 在 ubuntu 14.04 上永久移动错误
- gradle - 无法为 org.gradle.api.internal.tasks.DefaultSourceSetContainer 类型的 SourceSet 容器上的参数找到方法 srcDirs()
- javascript - 如何在 JavaScript 中使用 $.getJSON 来检索 python 文件数据?
- matlab - 改变matlab中的输出顺序