Discuss / Python / 怎样列绝对路径的文件?

怎样列绝对路径的文件?

Topic source

i_燊哥仔

#1 Created at ... [Delete] [Delete and Lock User]

请问能不能列一个绝对路径下的文件呢?我这样列返回了一个空list

import os
all_file = [x for x in os.listdir('D:/下载/My Work/') if os.path.isfile(x)]
print(all_file)

Nicktimebreak

#2 Created at ... [Delete] [Delete and Lock User]
import os
s= 'D://下载//My Work'
f = [x for x in os.listdir(s) if os.path.isfile(os.path.join(s,x))]

  • 1

Reply