首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >40-字符串方法

40-字符串方法

作者头像
凯茜的老爸
发布2018-09-11 14:46:36
2770
发布2018-09-11 14:46:36
举报
文章被收录于专栏:python百例python百例
py_str = 'hello world!'
py_str.capitalize()
py_str.title()
py_str.center(50)
py_str.center(50, '#')
py_str.ljust(50, '*')
py_str.rjust(50, '*')
py_str.count('l')  # 统计l出现的次数
py_str.count('lo')
py_str.endswith('!')  # 以!结尾吗?
py_str.endswith('d!')
py_str.startswith('a')  # 以a开头吗?
py_str.islower()  # 字母都是小写的?其他字符不考虑
py_str.isupper()  # 字母都是大写的?其他字符不考虑
'Hao123'.isdigit()  # 所有字符都是数字吗?
'Hao123'.isalnum()  # 所有字符都是字母数字?
'  hello\t    '.strip()  # 去除两端空白字符,常用
'  hello\t    '.lstrip()
'  hello\t    '.rstrip()
'how are you?'.split()
'hello.tar.gz'.split('.')
'.'.join(['hello', 'tar', 'gz'])
'-'.join(['hello', 'tar', 'gz'])
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.07.31 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档