str常用函数endswith()、split()、strip()
发布日期:2021-05-07 14:28:31 浏览次数:29 分类:原创文章

本文共 371 字,大约阅读时间需要 1 分钟。

print(type('100m'.endswith('m')))   # 判断目标字符串是否以某字符结尾print('100m'.endswith('m'))>> <class 'bool'>>> Trueprint(type('100m100m1'.split('m')))   # 将目标字符串以某字符分离print('100m100m1'.split('m'))>> <class 'list'>>> ['100', '100', '1']print(type('100m100m11'.strip('m')))   # 去除目标字符串尾部的某类字符print('100m100m11mmm'.strip('m'))>> <class 'str'>>> 100m100m11

.
.
.
2019-03-20 15:37:48写于上海

上一篇:timedelta获取时间差秒数.seconds和.total_seconds()的区别
下一篇:《经济机器是怎样运行的》笔记(二)

发表评论

最新留言

表示我来过!
[***.240.166.169]2025年04月12日 04时50分13秒