![](/img/trans.png)
[英]importing numpy works with interpreter but not fully with pyscripter in python
[英]Import a module works in PyScripter but not in Python Interpreter
我试图通过将可读变量替换为不可读变量来加密模块(ency0)。 加密模块(ency1)在PyScripter中有效,但在Python Interpreter中无效。
# ency0 module:
a,b = 2, 3
_,__ = a,b
# ency1 module:
import ency0
print 5*_+6*__
# expect result = 28 #
# In Python Interpreter:
>>>import ency0
>>>import ency1
Traceback <most recent call last>:
File "<stndin>", line 1, in <module>
File "ency1.py", line 13, in <module>
print 5*_ + 6*__
NameError: name '_' is not defined
>>>
在PyScripter中,只要先运行ency0,然后再运行ency1,我就可以得到正确的结果28。 如果仅运行ency1,则会收到未定义名称“ _”的错误消息。
但是在Python解释器中,我始终会收到一条错误消息:无论是否预先运行ency0,都未定义名称'_'。
我相信我错过了一些非常基本的语句,默认情况下始终包含在PyScripter中。
这是一个错误,因为您应该以
ency0._
如果您只想使用_请使用
from ency0 import *
代替
import ency0
您可以始终使用dir()打印本地变量列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.