我不知道它爲什麼不起作用;它返回此錯誤:TypeError:my_function()需要正好4個參數(給出5個)
TypeError: create_selected_properties_json_doc() takes exactly 4 arguments (5 given)
代碼:
def another_function():
confirmed_diagnostic_keys = [some, keys]
generalized_stage_keys = [some, keys]
stage_acording_to_uicc_keys = [some, keys]
self.create_selected_properties_json_doc(self, form, 'hallelluja', confirmed_diagnostic_keys)
self.create_selected_properties_json_doc(self, form, 'mashalla', generalized_stage_keys)
self.create_selected_properties_json_doc(self, form, "heheeyy", stage_acording_to_uicc_keys)
def create_selected_properties_json_doc(self, form, json_obj_key, form_element_ids):
# Create an empty dictionary
json_obj[json_obj_key] = {}
#Loop through the keys in list
for key in form_element_ids:
#check if the keys matches any of form's key
if key in form:
#Add values of form elements to the dictionary properties
json_obj[json_obj_key][key] = form[key]
else:
# Otherwise add "Jo" to the respective dictionary property
json_obj[json_obj_key][key] = 'NO'
return json_obj
'self'隱式傳遞,您不需要手動執行 - 您實際上正在調用'Class.method(self,self,...)'。 – jonrsharpe 2014-09-12 10:32:38