升级 Ubuntu 后,我的 Python 更改为 2.6.6 并且我的 app.py 停止工作打电话时
sys.stdout.write(curses.tigetstr('civis'))
它写道:
Traceback (most recent call last):
File "app.py", line 60, in <module>
sys.stdout.write(curses.tigetstr('civis'))
TypeError: argument 1 must be string or read-only character buffer, not None
我应该更改我的代码以使用较新版本的 Python 吗?
阅读documentation :
curses.tigetstr(capname)
Return the value of the string capability corresponding to the terminfo capability name capname. None isreturned if capname is not a string capability, or is canceled orabsent from the terminal description.
我认为问题可能出在终端描述上。我在 Ubuntu 11.10 上运行 python 2.7.2,以下代码不会引发任何异常:
import sys
import curses
curses.setupterm()
sys.stdout.write(curses.tigetstr('civis'))
这对你有用吗?如果是,您的问题可能与调用 curses.tigestr
之前的某些终端设置有关...
我是一名优秀的程序员,十分优秀!