下面是导致此错误的代码:TypeError: argument of type 'HTML' is not iterable
from prompt_toolkit import prompt
from prompt_toolkit.formatted_text import FormattedText, HTML
def get_input():
prompt_text = [
("class:prompt-prefix", HTML('<ansired><b>{}</b></ansired>'.format('your input > '))),
("", '')
]
placeholder = HTML('<b>enter `q` or `exit` to exit </b>')
return prompt(prompt_text, placeholder=placeholder, default='').lower()
我进行了测试,发现是prompt_text
引入了错误,我将其更改为:
prompt_text = HTML('<ansired><b>{}</b></ansired>'.format('your input \> '))
# escape > character or not does not matter, I found
还是不行,怎么修复这个bug?
1条答案
按热度按时间2ul0zpep1#
经过一些尝试和错误,我做到了: