@Python - NameError:未定义全局名称“select”

问题描述 投票:0回答:1

我在调用具有 select 的函数之前使用了

import select

我使用了如下所示的选择:

rl, wl, xl = select.select([stdout.channel], [], [], 0.0)

这里

stdout.channel
是我通过 paramiko 从 SSH 连接读取的内容。

堆栈跟踪:

File "C:\Code\Test.py", line 84, in Test

rl, wl, xl = select.select([stdout.channel], [], [], 0.0)
NameError: global name 'select' is not defined
python select paramiko
1个回答
0
投票

观察:

  1. 从命令行运行 python 脚本时 - 效果很好。不会出现此类错误。

  2. 使用 ECLIPSE 运行相同的脚本时,我看到如上所述的错误。

解决方案:

我使用以下方式导入了选择:

import select as something

现在,当我在脚本中使用它时,错误消失了。

rl, wl, xl = something.select([stdout.channel], [], [], 0.0)
© www.soinside.com 2019 - 2024. All rights reserved.