天天看點

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,如需轉載請自行聯系原作者