文章详情页
Python字符串转大小写问题
浏览:271日期: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. python - pip install出现下面图中的报错 什么原因?2. phpstudy8.1没集成mysql-front3. php工具中的mysql还是5.1以下的,请问如何才能升级到5.1以上?4. mysql - owncloud 数据库错误 1045,太奇怪了。5. 怎么php怎么通过数组显示sql查询结果呢,查询结果有多条,如图。我要forsearch里面echo6. 登录密码 什么情况???7. mysql 启动不了8. 多维数组遍历,求大佬解答???9. yii2 - MySQL [23000] Column cannot be null10. javascript - 微信小程序不支持<br> <p>等标签
排行榜

网公网安备