且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python列表的特殊用法

更新时间:2022-09-24 18:38:43

#!/usr/bin/python
# -*- coding:UTF-8 -*-

 

list = ["a","b","c"]
list2 = ["a","c",list]
print list[0]
list3 = [i for i in list if i not in list2]
print list
print list2
print list3

结果:

a
['a', 'b', 'c']
['a', 'c', ['a', 'b', 'c']]
['b']
















本文转sinojelly51CTO博客,原文链接:http://blog.51cto.com/pnig0s1992/358504,如需转载请自行联系原作者