2017-05-29 116 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)