Discuss / Python / 提问

提问

Topic source

ForRealHH

#1 Created at ... [Delete] [Delete and Lock User]

不知道这样的理解对不对

因为set里的key都是str的 不可变 因此set无法使用replace?

不理解你的问题,replace本身就不是对set的方法

渊博孙

#3 Created at ... [Delete] [Delete and Lock User]

兄弟,你没有看到问题的本质,本质是:改变常字符串的动作没有在常字符串上进行,而是将改变后的结果存储在另外一块内存中,然后返回。这下明白了没?


  • 1

Reply