![](/img/trans.png)
[英]How to find the size of all files in a directory and all its sub-directories?
[英]glob.iglob to find all .txt files in all sub-directories yields error
簡單的代碼給出了以下錯誤。 它直接來自文檔( https://docs.python.org/3/library/glob.html )
TypeError: iglob() got an unexpected keyword argument 'recursive'
import glob
for filename in glob.iglob('C:\\**\\*txt', recursive=True):
print filename
看來你正在使用Python 2.7並閱讀Python 3.5文檔。
在python 3.5中添加了recursive
參數,這意味着版本3.4.3
也存在這個問題。
如果您不想升級python版本,可以使用glob2 ,它默認支持遞歸調用( **
)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.