简体   繁体   English

windows-curses 无法处理导入错误

[英]windows-curses not working with an import error

I'm just doing some testing with windows-curses (2.3.0) and I was using this code and it gave me an error.我只是在用 windows-curses (2.3.0) 做一些测试,我正在使用这段代码,它给了我一个错误。 The code and error are below.代码和错误如下。

Code:代码:

import curses
from curses import wrapper

def main(stdscr):
    stdscr.clear()
    stdscr.addstr("Hello World")
    stdscr.refresh()
    stdscr.getch()

wrapper(main)

Error:错误:

Traceback (most recent call last):
  File "C:\Users\norbe\OneDrive\Desktop\Projects\Testing\Curses\curses.py", line 1, in <module>
    import curses
  File "C:\Users\norbe\OneDrive\Desktop\Projects\Testing\Curses\curses.py", line 2, in <module>
    from curses import wrapper
ImportError: cannot import name 'wrapper' from partially initialized module 'curses' (most likely due to a circular import) 

The code already imported curses and its context (methods and variables) binded to it.代码已经导入curses和它的上下文(方法和变量)绑定到它。 It means that wrapper is already identified by python.这意味着wrapper已经被 python 识别。

Try this:尝试这个:

import curses
wrapper = curses.wrapper

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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