print ("Address book")
print ("~~~~~~~~~~~~~")
print ("Welcome to your address book")
yn = ""
while yn != "n":
yn = input ("Would you like to search for a user? (Y/N) ")
if yn == "y":
search = input ("Would you like to search by surname (S) or month of birth (M) ")
if search.lower() == "s":
surname = input ("Please enter the surname: ")
for line in open("datafile.txt"):
if surname in line:
print(line)
elif search.lower() == "m":
DMY = input("please enter your date of birth you are looking for (date/month/year) : ")
DMY = DMY.split("/")
DMY = DMY[1]
for line in open("datafile.txt"):
if DMY in line:
print(line)
else:
print ("Sorry you can not do this please try again.")
elif yn == "n":
print("Goodbye")
else:
print("Sorry you can not do this please try again.")
答案 0 :(得分:0)
尝试打印(“欢迎使用地址簿,这会搜索姓氏或地址。”)