我在關注Curses programming HowTo on the Python site,但我遇到了一個相當奇怪的問題。Curses returned AttributeError:'module'object has no attribute'initscr'
我的代碼目前很短,實際上並沒有做任何事情因爲這個錯誤,我還沒有能夠繼續前進。這裏是我的代碼:
import curses
#from curses import wrapper
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
def main(stdscr):
begin_x = 20; begin_y = 7
height = 5; width = 40
win = curses.newwin(height, width, begin_y, begin_x)
stdscr.refresh()
stdscr.getkey()
if __name__ == '__main__':
wrapper(main)
和回溯:
Traceback (most recent call last):
File "curses.py", line 1, in <module>
import curses
File "/home/nate/Documents/Programming/Python/curses.py", line 4, in <module>
stdscr = curses.initscr()
AttributeError: 'module' object has no attribute 'initscr'
我註釋掉from curses import wrapper
,因爲這是給我的另一個錯誤,
Traceback (most recent call last):
File "curses.py", line 1, in <module>
import curses
File "/home/nate/Documents/Programming/Python/curses.py", line 2, in <module>
from curses import wrapper
ImportError: cannot import name wrapper
但我想這將是一個問題。
我現在正在學習單詞教程,以瞭解詛咒,但是目前唯一讓我做的事情就是使用指向Python的curses:P。
我在Ubuntu 13.10執行Python 3.3.2,所以this question無關這一點,因爲他使用的是Windows,我不(謝天謝地:d)
爲什麼我沒有能夠做到這一點?我直接從Python網站複製它,所以你會認爲它會起作用!
哦,當然......我不能相信我那樣做了:P感謝:D –
如果錯誤仍然存在,請檢查同一文件夾中的curses.pyc文件,並將其刪除。 –