簡體   English   中英

glob.iglob查找所有子目錄中的所有.txt文件會產生錯誤

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM