```python
def list_arg(*test_list:int):
for i in test_list:
print(i)
list_arg(*[1,2])
def list_arg(test_list:list[int]):
for i in test_list:
print(i)
list_arg([1,2])
```
之前一直是用的 list, 因为本来就是就 list,(不是 list 我就[int]包装一下),所以也没多想,今天看 nonebot 的时候看到有这种用法,想问问大家这俩种大家会怎么选呢, 在参数是
**int|list[int]**
的情况下
```python
def deep_update(
mapping: dict[K, Any], *updating_mappings: dict[K, Any]
) -> dict[K, Any]:
"""深度更新合并字典"""
updated_mapping = mapping.copy()
for updating_mapping in updating_mappings:
for k, v in updating_mapping.items():
if (
k in updated_mapping
and isinstance(updated_mapping[k], dict)
and isinstance(v, dict)
):
updated_mapping[k] = deep_update(updated_mapping[k], v)
else:
updated_mapping[k] = v
return updated_mapping
``` |
|