我正在學習 Python 函數的在線課程。我收到一個 NameError ,如下所示。有人能弄清楚為什么我會收到這樣的錯誤嗎?def student_details (**details_dictionary): if 'name' in details : print ("Name:", details['name'] ) if 'age' in details : print ("Age:", details['age'] ) if 'college' in details : print ("College:", details['college'] )student_details(name="John") NameError Traceback (most recent call last) <ipython-input-24-9617ce938851> in <module> ----> 1 student_details(name="John") <ipython-input-23-1424bf8f28d7> in student_details(**details_dictionary) 1 def student_details (**details_dictionary): ----> 2 if 'name' in details : 3 print ("Name:", details['name'] ) 4 if 'age' in details : 5 print ("Age:", details['age'] )NameError: name 'details' is not defined
為什么我收到“名稱未定義”錯誤消息?
慕婉清6462132
2022-10-18 17:16:21