【发布时间】:2018-09-13 17:08:08
【问题描述】:
我有一个显示所选目录中存在的文件列表的功能,然后用户输入搜索的单词,程序在后台读取这些文件以找到匹配的单词,最后它覆盖现有列表只显示包含匹配单词的文件。
问题在于 while 循环 系统显示此错误:
而索引
builtins.TypeError: 'int' 类型的对象没有 len()
代码:
def listFiles(self):
readedFileList = []
index = 0
while index < len(self.listWidgetPDFlist.count()):
readedFileList.append(self.listWidgetPDFlist.item(index))
print(readedFileList)
try:
for file in readedFileList:
with open(file) as lstf:
filesReaded = lstf.read()
print(filesReaded)
return(filesReaded)
except Exception as e:
print("the selected file is not readble because : {0}".format(e))
【问题讨论】:
标签: python pyqt pyqt5 qlistwidget qlistwidgetitem