输入关键字 抓取所有网页(Iasimpletoto )

优采云 发布时间: 2021-12-08 10:18

  输入关键字 抓取所有网页(Iasimpletoto

)

  基本上,我有一个简单的功能让用户输入信息以创建记录,然后我希望用户能够从“姓氏”调用特定列表并显示与其关联的整个列表。基本上,我有一个简单的功能供用户输入信息以创建记录,然后我希望用户能够从“姓氏”中调用特定列表并显示与其关联的整个列表。我尝试使用 if 函数,但可能索引会更好,因为它是一个列表?我尝试使用 if 函数,但可能索引会更好,因为它是一个列表?我不确定。我不确定。有小费吗?有什么提示吗?

   def main():

print("""

**********************************************

RECORDS MANAGER

**********************************************

1.Create a record

2.Show a record(s) [Enter a Last Name]:

3.Delete a record [Enter a Last Name]:

4.Display All Records [Ascending Order]:

5.Exit

""")

record = []

ans = True

def create():

student_id = str(input("Enter the student ID: "))

firstname = str(input("Enter the First name: "))

lastname = str(input("Enter the Last name: "))

age = str(input("Enter the Age: "))

address = str(input("Enter the Address: "))

phone_number = str(input("Enter the Phone number: "))

si = student_id

fn = firstname

ln = lastname

a = age

adr = address

pn = phone_number

name = f"StudentID: {si}, First name: {fn}, Last name: {ln}, Age: {a}, Address: {adr}, Phone number: {pn}"

print(name)

record.append(name)

if len(record) >= 5:

print("You cannot add any more entries, consider deleting some")

return

question = str(input("Would you like to add another record? (y/n): "))

if question == "y":

create()

if question == "n":

return

return ln, name

def read():

print(*record, sep="\n")

# This is where the user would search by the last name

def search():

name = str(input("Enter the last name of the student: "))

for ln in record:

if ln in name:

print(ln)

while ans:

main()

ans = str(input("Enter your option [1 - 5]: "))

if ans == "1":

create()

elif ans == "2":

print("\nShow a record")

search()

elif ans == "3":

print("\nDelete a record")

elif ans == "4":

print("\n Displaying all records")

read()

elif ans == "5":

print("\n Goodbye")

break

else:

print("\n Not Valid Choice Try again")

0 个评论

要回复文章请先登录注册


官方客服QQ群

微信人工客服

QQ人工客服


线