猫史档案馆


【作品展示】图书管喵V3.0

用户:ZCH123AbaB退喵倒438894ZCH123AbaB退喵倒438894查看:0 回复:0 评论:0 创建时间:2021-01-30T15:17:51


【作品展示】

center_image

【作品介绍】

这是一个模拟图书馆,选end结束管理图书,0书单,1借书(借书时随机生成用户ID),2还书(还书时将用户ID重置)。

【作品源代码】

# 创建书单

tick = 0
lib = ['哈利波特', '流浪地球', '封神演义', '三国演义', '红楼梦', '西游记', '水浒传']
print('欢迎来到智能图书馆V3.0')
while True:
    print('end:结束管理图书', '0:展示书单', '1:借书', '2:还书')
    message = input('Can i wait you anything?')
    # 结束管理图书
    if (message == 'end'):
        break
    # 展示书单
    if (message == '0'):
        print('booklist:')
        for x in lib:
            if ('#' not in x):
                print((('《' + x) + '》'))
            else:
                continue
    # 借书
    tick += 1
    if (tick == 1):
        if (message == '1'):
            book = input('book?')
            if (book in lib):
                print('OK,your book is passing')
                user = input('user?')
                userID = int(random.randint(1000000, 4000000))
                bo = (((book + '#') + user) + str(userID))
                print(((('Your ID is:' + '[') + str(userID)) + ']'))
                lib.append(bo)
                lib.remove(book)
    else:
        print('You should put your first one in library!')
    # 还书
    if (message == '2'):
        book = input('book?')
        user = input('user?')
        ID = input('userID?')
        bo = (((book + '#') + user) + str(userID))
        if (bo in lib):
            userID = int(userID)
            ID = int(ID)
            if (userID == ID):
                lib.append(book)
                lib.remove(bo)
                print('√ sucsess')
                userID = 0
                tick = 0
            else:
                print('× not sucsess')
        else:
            print('× not sucsess')

【提示】

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

https://python.codemao.cn





回复

上一页1 页 / 共 0下一页