简体   繁体   English

导入模块,但解释器无法识别该模块python中的功能

[英]Importing a module but the interpreter is not recognizing the function in that module python

I am importing a tokenize module to my project. 我正在将标记化模块导入到我的项目中。 Tokenize imports regexp.py 标记导入regexp.py

When I try to call a function located in regexp.py like that in my program 当我尝试在程序中调用位于regexp.py中的函数时

m = tokenize.regexp_tokenize(itemToString.lower(), n)

I get an error 'module' object has no attribute 'regexp_tokenize'. 我收到一个错误的“模块”对象,没有属性“ regexp_tokenize”。

regexp_tokenize is a function in regexp.py. regexp_tokenize是regexp.py中的一个函数。

Any idea what could be the problem? 知道可能是什么问题吗? Thanks in advance 提前致谢

You said yourself that you imported tokenize, not regexp. 您说自己是导入的tokenize,而不是regexp。 If regexp_tokenize is in regexp, you would need to import regexp yourself. 如果regexp_tokenize位于regexp中,则需要自己导入regexp。

You could access it via tokenzie.regexp.regexp_tokenize , but that's not usual practice. 可以通过tokenzie.regexp.regexp_tokenize访问它,但这不是通常的做法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM