小编Tob*_*byo的帖子

TypeError:'function'对象不可迭代

直到最近这段代码才有效.我添加了一个函数来提示用户输入文件名和扩展名,然后这不起作用,所以我使用了这个版本.现在,当我尝试运行它时,我得到了这个:

Traceback (most recent call last):
  File "C:/Code/Samples/Dates/2015-06-07/Large-Scale Data Parsing/Parser/Single_File_Multistep_Counter.py", line 53, in <module>
main()
  File "C:/Code/Samples/Dates/2015-06-07/Large-Scale Data Parsing/Parser/Single_File_Multistep_Counter.py", line 51, in main
writer(final_counts(intermediate_count))
  File "C:/Code/Samples/Dates/2015-06-07/Large-Scale Data Parsing/Parser/Single_File_Multistep_Counter.py", line 31, in final_counts
for file_path in intermediate_file_list:
TypeError: 'function' object is not iterable
Run Code Online (Sandbox Code Playgroud)

我也不完全确定错误意味着什么,并且在研究之后我只能在函数中发现python对象不可迭代错误python3 TypeError:'function'对象不可迭代但不能解决我的问题.

下面是给我错误的代码:

def final_counts(intermediate_file_list):
    date_list = {}
    for file_path in intermediate_file_list:
        with open(file_path, "r") as f:
            for line in f:
                tockens = line.split(",")
                if tockens[0] in date_list:
                    date_list[tockens[0]] = date_list[tockens[0]] + …
Run Code Online (Sandbox Code Playgroud)

python python-2.7

1
推荐指数
1
解决办法
7534
查看次数

标签 统计

python ×1

python-2.7 ×1