对字符串进行分割,text.split(str, num)
str -- 分隔符,默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等。
num -- 分割次数。默认为 -1, 即分隔所有。
>>> text = "this is key=value=use"
>>> print(text.split())
['this', 'is', 'key=value=use']
>>> print(text.split('='))
['this is key', 'value', 'use']
>>> print(text.split('=',1))
['this is key', 'value=use']
统计,统计指定字符个数,统计开始/末尾几个0
>>> text = '0110110110000'
>>> print(text.count('0'))
7
>>> print(text.rstrip('0'))
011011011
>>> print(text)
0110110110000
>>> print(len(text)-len(text.rstrip('0')))
4
>>> print(len(text)-len(text.lstrip('0')))
1