天天看点

Python列表的特殊用法

#!/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,如需转载请自行联系原作者