【python零基础入门】python中几种集合用法小知识

哈喽!同学们,今天小编和大家分享一下Python中几种集合用法小知识!
#remove 删除元素

s1 = {1,2,3,4,5}

s1.remove(2)

print(s1)

{1, 3, 4, 5}
#pop 剪切

s1 = {1,2,3,4,5}

res = s1.pop()

print(res)

1
#add 添加

s1 = {1,2,3,4,5}

s1.add(‘250’)

print(s1)

{1,

【python零基础入门】python中几种集合用法小知识最先出现在Python成神之路

版权声明:
作者:倾城
链接:https://www.techfm.club/p/20680.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>