标签:style color io os ar for sp div art
Python中sequence主要包含存储单个元素序列和两个元素对的序列,str就是一个字符容器。
单元素序列主要有以下类型:
双元素序列则主要是关联数组:
Operation | Result | Notes |
---|---|---|
x in s | True if an item of s is equal to x, else False | (1) |
x not in s | False if an item of s is equal to x, else True | (1) |
s + t | the concatenation of s and t | (6) |
s * n, n * s | n shallow copies of s concatenated | (2) |
s[i] | ith item of s, origin 0 | (3) |
s[i:j] | slice of s from i to j | (3)(4) |
s[i:j:k] | slice of s from i to j with step k | (3)(5) |
len(s) | length of s | |
min(s) | smallest item of s | |
max(s) | largest item of s | |
s.index(x) | index of the first occurrence of x in s | |
s.count(x) | total number of occurrences of x in s |
Operation | Result | Notes |
---|---|---|
s[i] = x | item i of s is replaced by x | |
s[i:j] = t | slice of s from i to j is replaced by the contents of the iterable t | |
del s[i:j] | same as s[i:j] = [] | |
s[i:j:k] = t | the elements of s[i:j:k] are replaced by those of t | (1) |
del s[i:j:k] | removes the elements of s[i:j:k] from the list | |
s.append(x) | same as s[len(s):len(s)] = [x] | (2) |
s.extend(x) | same as s[len(s):len(s)] = x | (3) |
s.count(x) | return number of i‘s for which s[i] == x | |
s.index(x[, i[, j]]) | return smallest k such that s[k] == x and i <= k < j | (4) |
s.insert(i, x) | same as s[i:i] = [x] | (5) |
s.pop([i]) | same as x = s[i]; del s[i]; return x | (6) |
s.remove(x) | same as del s[s.index(x)] | (4) |
s.reverse() | reverses the items of s in place | (7) |
s.sort([cmp[, key[, reverse]]]) | sort the items of s in place | (7)(8)(9)(10) |
标签:style color io os ar for sp div art
原文地址:http://blog.csdn.net/jinjiating/article/details/39556821