2021
03-10
03-10
python 集合set中 add与update区别介绍
集合set是一个无序不重复元素的集set(['hello','hello','hi'])#{'hello','hi'}set('hellohellohi')#{'','e','h','i','l','o'}set.add()与set.update()的区别myset1=set()myset1.add('hello')#{'hello'}myset1.update('world')#{'d','hello','l','o','r','w'}myset2=set()myset2.add('123')myset2.update('123')#{'1','123','2','3'}补充:在python中的set操作中添加vs更新如果我只想在集合中添加单个值,那...
继续阅读 >