gpt4 book ai didi

python-2.7 - 如何使用 stdscr.addstr() (curses) 打印 unicode 字符

转载 作者:行者123 更新时间:2023-12-01 00:17:35 25 4
gpt4 key购买 nike

我知道如何使用 print() 函数来打印 unicode 字符,但我不知道如何使用 stdscr.addstr() 来打印

我在 Linux 操作系统上使用 python 2.7

谢谢

最佳答案

我很确定您需要对字符串进行编码。docs阅读:

Since version 5.4, the ncurses library decides how to interpret non-ASCII data using the nl_langinfo function. That means that you have to call locale.setlocale() in the application and encode Unicode strings using one of the system’s available encodings.

这个例子在 2.7.12 中对我有用

import locale
locale.setlocale(locale.LC_ALL, '')
stdscr.addstr(0, 0, mystring.encode('UTF-8'))

关于python-2.7 - 如何使用 stdscr.addstr() (curses) 打印 unicode 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38491245/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com