for.py 1.0 KB
Newer Older
F
feilong 已提交
1
# -*- coding: UTF-8 -*-
F
feilong 已提交
2
# 作者:huanhuilong
F
feilong 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# 标题:Python 循环1
# 描述:使用 for 遍历打印列表信息

def test(list):
    i = 0
    for item in list:
        print('')
        print("## 第{}条信息".format(i))
        print("* id: {}".format(item['id']))
        print("* number: {}".format(item['number']))
        print("* title: {}".format(item['title']))
        print("* body: {}".format(item['body']))
        i += 1


if __name__ == '__main__':
    list = [
        {
            "id": 966024429,
            "number": 2341,
            "title": "Question about license.",
            "body": "I would like to create a [winget](https://github.com/microsoft/winget-cli) package for jq. 🙏🏻"
        },
        {

            "id": 962477084,
            "number": 2340,
            "title": "visibility of wiki pages",
            "body": "The visibility of wiki pages to search engines is generally limited; for example, the search result for \"jq Cookbook\" looks like this:"
        }
    ]

    test(list)