我在Unicurses工作,这是一个跨平台的python诅咒模块。我正试着把“@”字放在我的控制台中间。我的代码是:
from unicurses import *
def main():
stdscr = initscr()
max_y, max_x = getmaxyx( stdscr )
move( max_y/2, max_x/2 )
addstr("@")
#addstr(str(getmaxyx(stdscr)))
getch()
endwin()
return 0
if __name__ == "__main__" :
main()我一直搞错了
ctypes.ArgumentError was unhandled by user code
Message: argument 2: <class 'TypeError'>: Don't know how to convert parameter 2这一行:
move( max_y/2, max_x/2 )有没有人知道这个错误的原因和修复方法。谢谢!
发布于 2015-12-23 15:15:41
问题是,您要将浮点数传递给move函数,而应该传递整数。使用整数除法运算符//而不是/。
from unicurses import *
def main():
stdscr = initscr()
max_y, max_x = getmaxyx( stdscr )
move( max_y//2, max_x//2 ) # Use integer division to truncate the floats
addstr("@")
getch()
endwin()
return 0
if __name__ == "__main__" :
main()https://stackoverflow.com/questions/34431355
复制相似问题