国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

html - How to create a drop-down list in python by referencing the data in a json document.
怪我咯
怪我咯 2017-06-14 10:52:22
0
1
1066

I want to create a drop-down list in the input html, and the data in this drop-down list can reference my database json. What code should I write in my py file?

This is my input html. Although I can select it on the web page, it is too troublesome to fill it in one by one.

    <tr><td>起始機場: </td><td><input type="text" name="user_placeofdeparture" placeholder="請輸入機場名稱" <input list="airport">
    <datalist id="airport">
    <option value="北京西郊機場">
    <option value="內蒙古赤峰機場">
    <option value="長治王村機場">
    <option value="鄂爾多斯伊金霍洛機場">
    </datalist></td></tr>

    <tr><td>目的機場: </td><td><input type="text" name="user_destination" placeholder="請輸入機場名稱" <input list="airport">
    <datalist id="airport">
    <option value="北京首都國際機場">
    <option value="北京西郊機場">
    <option value="內蒙古赤峰機場">
    <option value="長治王村機場">
    <option value="鄂爾多斯伊金霍洛機場">
    </datalist> 
    </td></tr>

This is my py file. I have originally put the airport names in this txt, but my json also has this, and this json will be used to calculate longitude and latitude in the future.

I'm a little confused, I don't know how to use it. Pleading for help.

Intercept part of the content in the json document

    {"北京首都國際機場": { "latitude":40.08010101, "longitude":116.5849991},"北京西郊機場": { "latitude":39.96080017, "longitude":116.2570038},  "內蒙古赤峰機場": { "latitude":42.23500061, "longitude":118.9079971},"長治王村機場": { "latitude":36.24750137, "longitude":113.1259995},"鄂爾多斯伊金霍洛機場": { "latitude":39.49, "longitude":109.8613889},"大同機場": { "latitude":40.06029892, "longitude":113.4820023}}

Please help.

怪我咯
怪我咯

走同樣的路,發(fā)現(xiàn)不同的人生

reply all(1)
習慣沉默

First convert json to dict in python, and then take out the airport name:

import json

json_str = '{"北京首都國際機場": { "latitude":40.08010101, "longitude":116.5849991},"北京西郊機場": { "latitude":39.96080017, "longitude":116.2570038}, "內蒙古赤峰機場": { "latitude":42.23500061, "longitude":118.9079971},"長治王村機場": { "latitude":36.24750137, "longitude":113.1259995},"鄂爾多斯伊金霍洛機場": { "latitude":39.49, "longitude":109.8613889},"大同機場": { "latitude":40.06029892, "longitude":113.4820023}}'

airport_names = json.loads(json_str).keys()
// 然后把airport_names傳給模板

Then in the html file:

<datalist id="airport">
  {% for airport_name in airport_names %}
    <option value="{{ airport_name }}">
  {% endfor %}
</datalist>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template