2017-05-29 113 views
0

我已經查找了幾個小時,但找不到任何可用的東西,所以我想我只是直接問。我一直在嘗試使用curses,但無論我做什麼都行不通。我的代碼是 -導入詛咒出現錯誤

import curses 

from curses.wrapper import wrapper 


def main(scr): 
    scr.box() 
    scr.refresh() 
    c = scr.getch() 


wrapper(main) 

但我得到的錯誤是

Traceback (most recent call last): 
    File "/Users/Desktop/Code/Code.py", line 3, in <module> 
    from curses.wrapper import wrapper 
ModuleNotFoundError: No module named 'curses.wrapper' 

任何人都可以在這方面幫助?

+0

我還有一個問題是,如果我嘗試使用「從詛咒中導入包裝」,shell不能找到終端 –

回答

0

import不起作用,因爲您試圖將wrapper函數視爲一個類。這工作:

import curses 

# from curses.wrapper import wrapper 

def main(scr): 
    scr.box() 
    scr.refresh() 
    c = scr.getch() 

curses.wrapper(main) 

等做到這一點:

import curses 

from curses import wrapper 

def main(scr): 
    scr.box() 
    scr.refresh() 
    c = scr.getch() 

wrapper(main)