我有一个外部数据。我的文件夹中的json文件
{
"intents": [
{
"tag": "greeting",
"patterns": [
"Hi",
"Hey",
"How are you",
"Is anyone there?",
"Hello",
"Good day"
],
"responses": [
"Hey :-)",
"Hi there, what can I do for you?",
"Hi there, how can I help?"
]
},
{
"tag": "goodbye",
"patterns": ["Bye", "See you later", "Goodbye"],
"responses": [
"See you later, thanks for visiting",
"Have a nice day",
"Bye! Come back again soon."
]
},
{
"tag": "thanks",
"patterns": ["Thanks", "Thank you", "That's helpful", "Thank's a lot!"],
"responses": ["Happy to help!", "Any time!", "My pleasure"]
}
}
我只想返回所有“标签”并用html打印
我在flask中执行此操作,并希望在这个json文件中执行crud操作
这是我的应用。py文件
from flask import Flask , render_template,json
app = Flask(__name__)
jsnfile = 'data.json'
@app.route("/" )
def main():
with open(jsnfile) as f:
conttag = json.load(f)
for i in conttag['intents']:
return i['tag']
if(__name__ == "__main__"):
app.run()
这个的输出是“问候”,但我希望所有的标签都作为输出。