ModuleNotFoundError: No module named 'compiler'


修改别人项目的时候出现的错误:ModuleNotFoundError: No module named 'compiler'

参考https://blog.csdn.net/w5688414/article/details/78489277已解决。

删除from compiler.ast import flatten

添加以下代码:

import collections
def flatten(x):
    result = []
    for el in x:
        if isinstance(x, collections.Iterable) and not isinstance(el, str):
            result.extend(flatten(el))
        else:
            result.append(el)
    return result
 
print(flatten(["junk",["nested stuff"],[],[[]]]))  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM