def multi_row(test={}):
if not test.get("name"):
test["name"] = []
test.get("name").append("script boy")
return test
def once_row(test={}):
"""dict().setdefault(self, *args, **kwargs)
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
"""
test.setdefault("name", []).append("script boy")
return test
print(multi_row())
print(once_row())
浙公网安备 33010602011771号