【发布时间】:2013-03-16 17:05:55
【问题描述】:
我正在尝试获取特定目录中的文件列表并计算目录中的文件数。我总是收到以下错误:
WindowsError: [Error 3] The system cannot find the path specified: '/client_side/*.*'
我的代码是:
print len([name for name in os.listdir('/client_side/') if os.path.isfile(name)])
我按照here给出的代码示例进行操作。
我在 Pyscripter 上运行 Python 脚本,并且目录 /client_side/ 确实存在。我的 python 代码位于根文件夹中,并且有一个名为“client_side”的子文件夹。有人可以帮我解决这个问题吗?
【问题讨论】:
-
只是想知道这是否与 Windows 中的“/”有关!理想情况下,在 Windows 上,您应该有类似
os.path.join('C:','client_side')的内容
标签: python file directory listdir