How to list directory using Python
Possible Duplicate:
how to list all files of a directory in python
How do I list all directory content using python and add it to a list?
With Python, there so many ways to do this however, this one is the simplest i know.
Please check the comments for the specifics of the output.
from os import listdir
list = listdir("C:UsersHelloWorldPython Programs")
print list #Outputs the whole list
print len(list) #Checks for the length of the list
print list[26] #Outputs a specific element in the list
Good luck!
链接地址: http://www.djcxy.com/p/20046.html上一篇: 请帮助在Python中解释这段代码
下一篇: 如何使用Python列出目录