文章详情页
Python字符串转大小写问题
浏览:230日期: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. css - transform-origin 旋转参考点2. ubuntu系统php+apache web服务器异步方法不执行回调请教3. android 微信是如何实现即时更新好友头像的4. linux - ubuntu14安装mongodb出错5. node.js - koa2 如何获取参数?6. java - 关于京东单点登录认证的问题7. node.js - vue项目build后,打开监听port没问题,但是刷新页面后就挂掉了8. Python中的内列表问题,真的很困惑9. javascript - 为什么我的vue里的router-link不起作用10. centos7 关闭firewall nginx还是不能访问
排行榜

网公网安备