Directly through the following two examples:
- Use {} to clear dictionary value
>>> x = {}
>>> y = x
>>> x['key'] = 'value'
>>> x
{'key': 'value'}
>>> y
{'key': 'value'}
>>> x = {}
>>> x
{}
>>> y
{'key': 'value'}
>>>
- Use clear () to clear the dictionary value
>>> x = {}
>>> y = x
>>> x['key'] = 'value'
>>> x
{'key': 'value'}
>>> y
{'key': 'value'}
>>> x.clear()
>>> x
{}
>>> y
{}
Different methods can be used according to requirements.