ModuleNotFoundError: No module named 'compiler'

一、报错原因:python3 废除了包 compiler

二、解决方法:

把下面代码粘贴到你的程序里

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"],[],[[]]]))  

https://stackoverflow.com/questions/16176742/python-3-replacement-for-deprecated-compiler-ast-flatten-function

你可能感兴趣的:(python)