Python3/Cheetah3:“过滤器”类型的对象没有 len()

问题描述

Python:3.6.8 猎豹:3.2.4-1.el7 使用 2to3 程序将我的代码(Cheetah 外部)从 Python2 转换为 python3 并将 Cheetah2 替换为 Cheetah3 后,出现以下错误。我参考了一些关于 StackOverflow 本身的文章,发现在 Python2 中,过滤器返回一个列表,而在 python3 中,它返回一个需要转换为列表的迭代器。我查看了 Cheetah/Template.py,但不明白我应该在哪里进行建议的更改。

    open(output_file_name,'wb').write( str(result) )  File "/srv/data/3rdParty/Cheetah/Template.py",line 1053,in __unicode__
    return getattr(self,mainMethName)()
  File "cheetah_DynamicallyCompiledCheetahTemplate_1618855414_917998_66948.py",line 125,in respond
TypeError: object of type 'filter' has no len()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)