文章详情页
Python字符串转大小写问题
浏览:150日期:2022-06-27 16:02:46
问题描述
str.lower() 字符串全小写。str.upper() 字符串全大写。
>>> str = ’my world, MY PYTHON’>>> str.lower()’my world, my python’>>> str.upper()’MY WORLD, MY PYTHON’
如何才能使字符串每个单词首字母都大写? 使 str = ’My World, My Python’
问题解答
回答1:参考文章:Python字符串操作相关问题
字符串大小写转换str.lower() 字符串全小写。str.upper() 字符串全大写。str.capitalize() 字符串首字母大写。str.title() 字符串每个单词首字母都大写。
>>> str = ’my world, MY PYTHON’>>> str.lower()’my world, my python’>>> str.upper()’MY WORLD, MY PYTHON’>>> str.capitalize()’My world, my python’>>> str.title()’My World, My Python’回答2:
str.title()
相关文章:
1. docker gitlab 如何git clone?2. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””3. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?4. golang - 用IDE看docker源码时的小问题5. vim - docker中新的ubuntu12.04镜像,运行vi提示,找不到命名.6. 数据库 - mysql中怎样修改带点的字段名的位置?7. docker镜像push报错8. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?9. dockerfile - [docker build image失败- npm install]10. docker不显示端口映射呢?
排行榜

网公网安备