iT邦幫忙

0

python關於AttributeError: 'NoneType' object has no attribute 'fileno'的問題

  • 分享至 

  • xImage

剛接觸python,現在在學習curses,照著範例打,執行結果卻出現"AttributeError: 'NoneType' object has no attribute 'fileno'"

這是範例

import curses

def demo_win(stdscr):
    curses.mousemask(-1)
    stdscr.border()

    while True:
        e = stdscr.getch()
        if e == ord("q"):
            break
        if e == curses.KEY_MOUSE:
            _, x, y, _, _ = curses.getmouse()
            stdscr.addstr(2, 2, f"x: {x:02}, y: {y:02}")

if __name__ == "__main__":
    curses.wrapper(demo_win)

執行結果
Traceback (most recent call last):
File "pythonpy\first_1.py", line 17, in
curses.wrapper(demo_win)
File "Python\Python37\lib\curses_init_.py", line 73, in wrapper
stdscr = initscr()
File "Python\Python37\lib\curses_init_.py", line 30, in initscr
fd=_sys.stdout.fileno())
AttributeError: 'NoneType' object has no attribute 'fileno'

####python版本是3.7.3 電腦是windows64位元
curses函式庫是curses-2.2+utf8-cp37-cp37m-win_amd64.whl
####不知道是我安裝錯了還是程式有問題

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答