当前位置: 首页 > 图灵资讯 > 行业资讯> python中列表如何去除重复

python中列表如何去除重复

发布时间:2025-02-20 20:43:05

去除Python列表重复的方法:

Python内置的set函数可以去除列表中的重复元素,然后使用“set(列表)“语句可以重新列表”

示例代码如下:

x=[123、541、123、123、548、546、541、88、123、541]
b=set(x)
print(b)

结果如下:

微信截图_20200608093949.jpg

更多Python知识,请关注:Python自学网!!

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09