如何停止我的Python curses代码中发生的错误?

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

我对为什么每次运行一些curses代码时都会不断弹出此错误感到困惑。

代码:

import curses

stdscr = initscr()

输出:

Traceback (most recent call last):
  File "C:\Users\Abd-ur-Rahmaan\Desktop\Abd-Ur-Rahmaan Shabbir\Python coding\Python Advanced Shit\The first curses project\The first curses project.py", line 3, in <module>
    stdscr = curses.initscr()
  File "C:\Users\Abd-ur-Rahmaan\Desktop\lib\curses\__init__.py", line 30, in initscr
    fd=_sys.__stdout__.fileno())
AttributeError: 'NoneType' object has no attribute 'fileno'
python-3.x windows curses
2个回答
0
投票

Windows版本的Python不包含curses模块。提供了一个名为UniCurses的移植版本。您也可以尝试使用Fredrik Lundh编写的Console模块,该模块不使用与curses相同的API,而是提供可光标定位的文本输出,并且完全支持鼠标和键盘输入。

参考:https://docs.python.org/3/howto/curses.html


0
投票

将您的.py文件放在启用了PATH的位置(应为python文件夹,为标准格式)

pip安装Windows-curses

右键单击开始>运行

输入文件名(例如,snake.py)

运行

© www.soinside.com 2019 - 2024. All rights reserved.