如何使用flask在网页的一行中显示消息?我尝试了以下方法:
lines=sent_tokenize(s)
sentence_count=len(lines)
flash("no of sentences :",sentence_count)
但未显示sentence_count
。
答案 0 :(得分:0)
不确定是否正确,因为我缺少很多上下文信息,但是请尝试以下
consul-template
由于config.json
似乎将字符串作为第一个参数,并且lines=sent_tokenize(s)
sentence_count=len(lines)
flash("no of sentences: %d" % sentence_count)
返回一个整数,因此请将flash
放在len
字符串内
答案 1 :(得分:0)
使用python 3.7.6时,有几种方法可以实现
"no of sentences: {0}".format(sentence_count)
"no of sentences: {count}".format(count=sentence_count)
"no of sentences: %d" % sentence_count # %d for int, %s for string
f'no of sentences: {sentence_count}'