在Python中dict.clear()和赋值{}之间的区别 - Difference between dict.clear() and assigning {} in Python

2021/12/02 07:05
阅读数 0

问题:

In python, is there a difference between calling clear() and assigning {} to a dictionary? 在python中,调用clear()和为字典分配{}之间有区别吗? If yes, what is it? 如果是,那是什么? Example: 例:

d = {"stuff":"things"}
d.clear()   #this way
d = {}      #vs this way


解决方案:

参考: https://stackoom.com/en/question/1YE6
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部