2tu3-学无止境 python python3 数组去空值,去重

python3 数组去空值,去重

去空值

x = ["a", "", "", "","b"]
x = [i for i in x if i]
print(x)
["a","b"]

去重复

x = ["a", "", "", "","b"]
print(set(x))

{ '', 'a', 'b'}
本文来自网络,不代表2tu3-学无止境立场,转载请注明出处:https://2tu3.com/biji/163/

作者: 热心网友

上一篇
下一篇
返回顶部