python的字符串内建函数2

2024-10-15 07:31:51

python中string模块有很多字符串的方法,下面简单列几个方法。

python的字符串内建函数2

工具/原料

电脑

python

字符串内建函数:

1、string.count(str):返回str在string里面出现的次数。

python的字符串内建函数2python的字符串内建函数2

2、string.count(str, a, b):返回指定范围内str出现的次数。

python的字符串内建函数2python的字符串内建函数2

3、string.encode('U哌囿亡噱TF-8', 'strict'):以指定的编码格式编码string。

python的字符串内建函数2python的字符串内建函数2

4、string.expandtabs(ta水瑞侮瑜bsize=?):把字符串 string 中的 tab 符号转为空格,空格长度由tabsize决定,tab符号默认的空格数是 8。

python的字符串内建函数2python的字符串内建函数2
猜你喜欢