2012-09-22 62 views

回答

3

用Python,有很多方法可以做到這一點,但這是我知道的最簡單的方法。

請檢查輸出的具體內容的意見。

from os import listdir 
list = listdir("C:\Users\Hello\World\Python 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 

祝你好運!

+2

可能希望小心路徑中的反斜槓,因爲它們與字符串轉義字符發生衝突。 – icktoofay

+0

因此,在字符串之前加上「r」:'list = listdir(r「C:\ Users \ Hello \ World \ Python Programs」)' – Lior

+2

呃......回答你自己的問題,如果你找出答案,同時,但是......你爲什麼表現得好像你是兩個人? (例如w /「祝你好運!」) –