私は連絡先マネージャーを作成しました。
def look_up_contact():
print("-------------------------------------------------")
choice = input("Please enter the last name of the contact you would like to view: ")
print("-------------------------------------------------")
person_list = Contacts[choice]
try:
for person in person_list:
print("Contact: " + person.get_last_name() + ", " + person.get_first_name())
print("Phone Number: " + person.get_phone_num())
if type(person) == Friend:
print("Email: " + person.get_email())
print("Birthday: " + person.get_birth_date())
これを変更して、テキスト ファイルも参照するにはどうすればよいでしょうか。
基礎は理解できたが、これが難しかった
textcontacts = open( 'contacts.txt' )
また、'person' または txt で person が見つからなかった場合にエラー メッセージを追加することについて、フィードバックをお願いします。
try: メソッドを実行しようとしました
except Exception as ex:
print(' Sorry, The person you are looking for could not be found ')
私はpython 3.xを使用しています