📜  python函数返回字典 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:43.407000             🧑  作者: Mango

代码示例1
def query(id):
    for line in file:
        table = {}
        (table["ID"],table["name"],table["city"]) = line.split(";")
        if id == int(table["ID"]):
             file.close()
             return table
    # ID not found; close file and return empty dict
    file.close()
    return {}