python字典 items函数

    科技2022-07-16  107

    items函数会将字典以数列形式返回,且元素是键值对应的元组。

    d = {'one': 1, 'two': 2, 'three': 3} print(d.items()) dict_items([('one', 1), ('two', 2), ('three', 3)])

    有一个问题在于python3.0后还会输出dict_items()而不是单纯的数列

    Processed: 0.008, SQL: 8