问题描述
所以,我尝试了下面的程序来运行除 get_close_matches() 部分之外的所有工作
代码:
from difflib import get_close_matches
class Library:
def __init__(self,books):
self.books=books
def display_books(self):
print("-----Available Books-----")
for book in self.books:
print(book)
def borrow_books(self,borrow_book):
if borrow_book in self.books:
print("Get your book")
self.books.remove(borrow_book)
else:
print("Book not available")
def return_books(self,return_book):
print("You have returned the book")
self.books.append(return_book)
books=['C','C++','Java','Python']
o = Library(books)
msg="""
Select the choices below
1.display Book
2.Borrow Book
3.Recieve Book
"""
while True:
print(msg)
ch=int(input("Enter your Choice : "))
if ch == 1:
o.display_books()
elif ch == 2:
book = input("Enter the book name to borrow : ")
if book in books:
o.borrow_books(book)
elif get_close_matches(book,books):
chooice=input("Did you mean %s"%get_close_matches(book,books)[0],"Enter Y for yes N for no")
if chooice == "Y" or "y":
print( books[get_close_matches(book,books)[0]])
elif chooice == "N" or "n":
print( "Entered book is not available")
elif ch == 3:
book = input("Enter the book name to return : ")
o.return_books(book)
else:
print("Tq")
quit()
Select the choices below
1.display Book
2.Borrow Book
3.Recieve Book
输入您的选择:2 输入要借的书名:pyton 回溯(最近一次调用最后一次): 文件“library_management.py”,第 45 行,在 chooice=input("你的意思是 %s"%get_close_matches(book,"输入 Y 表示是 N 表示否") 类型错误:输入预计最多 1 个参数,得到 2
我不知道为什么我会遇到这个错误是我在某个地方搞砸了还是我错过了任何变量 plzz helo 我只是一个初学者,所以请帮助我
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)