博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python光荣之路测试开发班list学习笔记
阅读量:6810 次
发布时间:2019-06-26

本文共 2033 字,大约阅读时间需要 6 分钟。

# coding=utf-8book_list_in_library = []ready_borrow_book_list = []borrowed_book_list = []menu_info = """input 1:add new book to libraryinput 2:borrow book from libraryinput 3:list all books in libraryinput 4:list all borrowed books in libraryinput 5: list current books in libraryinput 6:lend a book"""def add_book():    global book_list_in_library    global ready_borrow_book_list    book_name = raw_input("please input the book name to add:")    book_list_in_library.append(book_name)    ready_borrow_book_list.append(book_name)def borrow_book():    global ready_borrow_book_list    global borrowed_book_list    while 1:        book_name = raw_input("please input the book name to borrow:")        if book_name in ready_borrow_book_list:            ready_borrow_book_list.remove(book_name)            borrowed_book_list.append(book_name)            print "borrow book done!"            break        else:            print "the book you borrow does not exist,try again!"def lend_book():    global ready_borrow_book_list    global borrowed_book_list    while 1:        book_name = raw_input("please input the book name to lend:")        if book_name in borrowed_book_list:            borrowed_book_list.remove(book_name)            ready_borrow_book_list.append(book_name)            print "lend book done!"            break        else:            print "the book you lend does not exist,try again!"while 1:    print menu_info    command = raw_input("please input your command:")    if command == "1":        add_book()        print ready_borrow_book_list        print book_list_in_library        continue    if command == "2":        borrow_book()    if command == "3":        print "all books are :", book_list_in_library    if command == "4":        print "borrowed books are :", borrowed_book_list    if command == "5":        print "current books in library are :", ready_borrow_book_list    if command == "6":        lend_book()    if command == "q":        break

心得:把功能分解,一个方法一个实现

转载于:https://blog.51cto.com/357712148/2051414

你可能感兴趣的文章
GO语言的开源库
查看>>
java中获取系统属性以及环境变量
查看>>
微信开发(03)之新建按钮时报错 errcode 40054
查看>>
TEA encryption with 128bit key
查看>>
操作系统定期定时执行python脚本
查看>>
TCP的拥塞控制
查看>>
FZU 1894 志愿者选拔 单调队列
查看>>
**app后端设计(10)--数据增量更新(省流量)
查看>>
用SoapUI进行Webservice的性能压力测试
查看>>
.NET反编译之manager,base.AutoScaleMode修复
查看>>
光看这图片就知道是大片--今天是五一劳动节尽管还是敲着代码(日常就是这样)然后想不出写什么了,也找不到好的素材,最后开心一下吧...
查看>>
希尔排序算法
查看>>
【Cocos2d-Js基础教学(3)各种基类的定义和使用】
查看>>
java.util.logging.Logger使用详解
查看>>
Sql Server -更新语句,修改的字段是日期时间型,修改其中的月份
查看>>
【转】linux下tty,控制台,虚拟终端,串口,console(控制台终端)详解----不错...
查看>>
Vertica增加一个数据存储的目录
查看>>
小小的告别一下这个博客
查看>>
【转】内核编译时, 到底用make clean, make mrproper还是make distclean(转载)
查看>>
The YubiKey NEO
查看>>