简体   繁体   中英

How to stop the error occuring in my Python curses code?

I'm confused about why this error keeps popping up whenever I run some curses code.

Code:

import curses

stdscr = initscr()

Output:

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'

The Windows version of Python doesn't include the curses module. A ported version called UniCurses is available. You could also try the Console module written by Fredrik Lundh, which doesn't use the same API as curses but provides cursor-addressable text output and full support for mouse and keyboard input.

Refer to: https://docs.python.org/3/howto/curses.html

put your.py file wherever you have PATH enabled (it should be the python folder as standart)

pip install windows-curses

right click on start > run

enter the name of the file (snake.py for example)

run

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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