def read_user_info(name):
    """从系统的用户数据库 /etc/passwd 中读取指定用户的基本信息，返回字典"""
    db = '/etc/passwd'
    info = [line.split(':') for line in open(db).read().splitlines()]
    user_info = [i for i in info if i[0] == name]
    if not user_info:   # 找不到用户
        return
    user_info = user_info[0]
    colnames = ('name', 'password', 'uid', 'gid', 'comment', 'home', 'shell')
    return dict(zip(colnames, user_info))