猫史档案馆


【Python作品分享】新的作品【作品秀】

用户:STAR超能星STAR超能星查看:0 回复:0 评论:0 创建时间:2020-01-28T17:12:47


【作品展示】

center_image

 

【作品介绍】

111

 

【作品源代码】

import easygui
from easygui import *
from os import *

Title = '账户管理系统'
main_choices = ('添加/删除账户', '激活/停用账户', '强制修改密码', '退出')
choices_1 = ('添加账户', '删除账户')
choices_2 = ('激活账户', '停用账户')


def cls():
    system('cls')
    return


def view_users():
    system('net user')
    return


def main():
    cls()
    operation = choicebox('请选择一个操作', Title, main_choices)
    if operation == main_choices[0]:
        add_or_remove_user()
    elif operation == main_choices[1]:
        enable_or_disable_user()
    elif operation == main_choices[2]:
        change_pwd()
    else:
        exit()


def add_or_remove_user():
    cls()
    operation = choicebox('请选择一个操作', Title, choices_1)
    if operation == choices_1[0]:
        add_user()
    elif operation == choices_1[1]:
        remove_user()
    else:
        main()


def enable_or_disable_user():
    cls()
    operation = choicebox('请选择一个操作', Title, choices_2)
    if operation == choices_2[0]:
        enable_user()
    elif operation == choices_2[1]:
        disable_user()
    else:
        main()


def add_user():
    cls()
    view_users()
    new_user = multpasswordbox('请输入账户信息', Title, ['用户名', '密码'])
    c喵 = 'net user '+new_user[0]+' "'+new_user[1]+'" /add'
    system(c喵)
    output = '已添喵密码为"'+new_user[1]+'"'
    msgbox(output, Title)
    main()


def remove_user():
    cls()
    view_users()
    removing_user = enterbox('请输入要移除的用户名', Title)
    c喵 = 'net user '+removing_user+' /delete'
    system(c喵)
    output = '已移除"'+removing_user+'"'
    msgbox(output, Title)
    main()


def enable_user():
    cls()
    view_users()
    target_user = enterbox('请输入要激活的用户名', Title)
    c喵 = 'net user '+target_user+' /active:yes'
    system(c喵)
    output = '已激活"'+target_user+'"'
    msgbox(output, Title)
    main()


def disable_user():
    cls()
    view_users()
    target_user = enterbox('请输入要停用的用户名', Title)
    c喵 = 'net user '+target_user+' /active:no'
    system(c喵)
    output = '已停用"'+target_user+'"'
    msgbox(output, Title)
    main()


def change_pwd():
    cls()
    view_users()
    target_user = enterbox('请输入要更改密码的用户名', Title)
    new_pwd = enterbox('请输入新密码', Title)
    c喵 = 'net user '+target_user+' "'+new_pwd+'"'
    system(c喵)
    output = '已更改"'+target_user+'"的密码为'+'"'+new_pwd+'"'
    msgbox(output, Title)
    main()


main()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页