Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于 train2.pkl 中from compiler.ast import flatten的问题 #41

Open
YuQuankun opened this issue Jun 4, 2020 · 1 comment
Open

Comments

@YuQuankun
Copy link

报错信息为:
Traceback (most recent call last):
File "train2pkl.py", line 94, in
from compiler.ast import flatten
ImportError: No module named 'compiler.ast'
网上查阅资料说是因为在python3以后这段话就被废除了,请问如何解决呢?

@jkx1206
Copy link

jkx1206 commented Jul 22, 2020

用下面函数替换就行
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants