info_email address

邮箱信息展示
博客内容展示了两个邮箱地址,分别为gxguo@isoftstone.com和yingqliu@isoftstone.com。
gxguo@isoftstone.com
yingqliu@isoftstone.com
def display_menu(): """Display the main menu options.""" print("Address Book Menu") print("1. Add a contact") print("2. View all contacts") print("3. Search for a contact") print("4. Delete a contact") print("5. Exit") def add_contact(address_book): print("Add New Contact") name = input("Enter contact name: ").strip() if not name: print("Error: Name cannot be empty!") return if any(contact['name'].lower() == name.lower() for contact in address_book): print(f"Error: Contact '{name}' already exists!") return phone = input("Enter phone number: ").strip() email = input("Enter email address: ").strip() contact = { 'name': name, 'phone': phone, 'email': email } address_book.append(contact) print(f"\nSuccess: Contact '{name}' added!") def view_contacts(address_book): print("All Contacts") if not address_book: print("No contacts found.") return print("{:<20} {:<15} {:<30}".format('Name', 'Phone', 'Email')) # Print each contact for contact in address_book: print("{:<20} {:<15} {:<30}".format( contact['name'], contact['phone'], contact['email'] )) print(f"Total contacts: {len(address_book)}") def search_contact(address_book): print("Search Contacts") search_term = input("Enter search term: ").strip().lower() if not search_term: print("Error: Search term cannot be empty!") return matches = [ contact for contact in address_book if search_term in contact['name'].lower() ] if not matches: print("\nNo matching contacts found.") return print(f"Found {len(matches)} matching contacts:") print("{:<20} {:<15} {:<30}".format('Name', 'Phone', 'Email')) for contact in matches: print("{:<20} {:<15} {:<30}".format( contact['name'], contact['phone'], contact['email'] )) def delete_contact(address_book): print("Delete Contact") name = input("Enter name to delete: ").strip() if not name: print("Error: Name cannot be empty!") return for i, contact in enumerate(address_book): if contact['name'].lower() == name.lower(): del address_book[i] print(f"\nSuccess: Contact '{contact['name']}' deleted!") return print("\nError: Contact not found.") def main(): address_book = [] while True: display_menu() choice = input("\nEnter your choice : ").strip() if not choice.isdigit(): print("\nInvalid selection. Please enter a number from 1 to 5.") continue choice = int(choice) if choice == 1: add_contact(address_book) elif choice == 2: view_contacts(address_book) elif choice == 3: search_contact(address_book) elif choice == 4: delete_contact(address_book) elif choice == 5: print("\nExiting program. Goodbye!") break else: print("\nInvalid selection. Please choose 1-5.") continue if __name__ == "__main__": main() 生成这个程序的测试日志
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值