py6_combined data

  • Combined data

Same as the definition in mathematics. In Python, Collection Data cannot be changed.
Using {} to display the Collection Data, using “,” to separate the elements in collection, using {} or set() to generate the collection.
If you want to establish a empty collection, you must use set() to generate the collection.

The calculation of collection:
S|T: return a new collection which comtained all the elements of S and T.
S-T, S&T, same as the definition in mathematics.
S^T: return a new collection which contained non-identical elements of set S and set T.
S <= T or S < T: return true or false, determines the sub-collection relationship of S and T.
S >=T or S > T: return true or false, determines the contain-relationship of S and T.
S |= T, S -= T, S &= T, S ^= T: update S with the new collection.

The functions of Collection data:
S.add(x): if x is not in S, than add the x to S.
S.discard(x): discard the x from S, if x is not in S, system would not show the error attention.
S.remove(x): discard the x from S, if x is not in S, system will SHOW the KeyError error attention.
S.clear(): remove all the elements in S.
S.pop(): return a random element in S, update S, if S is empty will system show the KeyError error attention.
S.copy(): copy the S.
len(S): return the total number of the elements in S.
x in S(x not in S): determine if the x in(or not in) S, than return true, else return false.
set(x): change the other type data x into Collection Type.

  • Tuple Data

Tuple Data is one of the String Type, WARNING: if the Tuple Data has been generated, it cannot be edited.
Using () or tuple() to generate, using “,” to separate the elements.

  • List Data

ls[i] = x: assign x to ls[i].
ls[i: j: k] = lt: using List lt to assign ls from i to j.
del ls[i]: delete the ith element from ls.
del ls[i: j: k]: delete the elements from i to j according to k.
ls *= n: copy ls n times.
ls.append(x): add an element x behind ls.
ls.clear(): delete all the elements in ls.
ls.copy(): generate a new list, using ls to assign this new list.
ls.insert(i, x): add an element x at ith in ls.
ls.pop(i): take out the element at ith in ls and delete this element.
ls.remove(x): delete the first x in ls.
ls.reverse(): reverse the elements in ls.4.Dictionary Datadel d[k]: delete the value corresponding to Dictionary d.
d.keys(): return all the Key Information in Dictionary d.
d.values(): return all the Value Information in Dictionary d.
d.items(): return all Key-Value Pair Information in Dictionary d.

  • Jieba Library

Jieba is a Chinese vocabulary library.
Accurancy Mode: cut the text accurantely without redundant words.
Full Mode: scan out all possible words with redundant words.
Search Engine Mode: re-cut the long words based on Accurancy Mode.
jieba.lcut(s): Accurancy Mode, return the result of separated words in List type.
jieba.lcut(s, cut_all = True): Full Mode, return the result of separated words in List type with redundant words.
jieba.lcut_for_search(s): Search Engine Mode, return the result of separated words in List type with redundant words.
jieba.add_word(w): add new word to separated-word dictionary.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值