python - 错误没有名为 curses 的模块

标签 python windows python-2.7 telnet curses

当我尝试运行以下代码时...

from telnetsrvlib import *

if __name__ == '__main__':
"Testing - Accept a single connection"
class TNS(SocketServer.TCPServer):
    allow_reuse_address = True

class TNH(TelnetHandler):
    def cmdECHO(self, params):
        """ [<arg> ...]
        Echo parameters
        Echo command line parameters back to user, one per line.
        """
        self.writeline("Parameters:")
        for item in params:
            self.writeline("\t%s" % item)
    def cmdTIME(self, params):
        """
        Print Time
        Added by dilbert
        """
        self.writeline(time.ctime())

logging.getLogger('').setLevel(logging.DEBUG)

tns = TNS(("0.0.0.0", 8023), TNH)
tns.serve_forever()

我收到这个错误

Traceback (most recent call last):
File ".\telserv.py", line 1, in <module>
from telnetsrvlib import *
File "C:\Python27\lib\site-packages\telnetsrvlib-1.0.2-py2.4.egg\telnetsrvlib.py", line 31, in <module>
import curses.ascii
  File "C:\Python27\lib\curses\__init__.py", line 15, in <module>
from _curses import *

我正在运行 python 2.7 并导入了 telnetsrvlib 库,我正在 Windows 7 上运行代码。我们将不胜感激。

最佳答案

您还可以从这里安装 curses 模块: http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses .

它允许在 Windows 上使用 python 的原生 curses,因此可以使用所有标准的 python curses 代码。

关于python - 错误没有名为 curses 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17410116/

相关文章:

python - 在 python 中读取 csv 文件时语法无效

python - 在 Python 中旋转图像

python - 奇怪的行为 : What does "12 in [12,13,14] == True" mean in Python

python - 读取文本文件并存储在列表列表中

python - 将许多变量传递给 Jinja render_template() 时的良好风格?

python - 安装 SOAPpy 模块的困难

linux - 如何使用 URL 重写在我的站点中反射(reflect)另一个站点?

windows - 以编程方式删除 .git .idx .pack 文件

python - Python 中 matplotlib 的 (x,y) 绘图替代方案是什么?

python - 在Python中随机查找列表中可用位置的高效算法