网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

python的字符串内建函数12

时间:2024-10-15 07:25:09

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

python的字符串内建函数12

工具/原料

python

电脑

字符串内建函数:

1、string.rstrip():删除字符串末尾的空格。

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

2、string.split(str):以str为分隔符切片字符串。

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

3、string.split(str, num):以str为分隔符切片字符串,如果num有值,则仅分隔num+1个子字符串。

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

4、string.swapcase():翻转字符串中的大小写。

python的字符串内建函数12python的字符串内建函数12
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com