文章详情页
Python字符串转大小写问题
浏览:48日期: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. 微信小程序如何加载h5页面2. python - 能通过CAN控制一部普通的家用轿车吗?3. php工具箱配置第二个vhost主机时不生效,报错You don’t have permission4. URL访问有问题啊5. mysql - oracle物化视图和临时表的区别是什么?6. MYSQL代码执行错误:FUNCTION any_value does not exist7. node.js - nodejs开发中常用的连接mysql的库8. 两个思路:python模拟登陆页面和模拟操作windows程序窗口提交请求9. paramiko - Python tempfile生成的文件能不能拷贝到远程服务器?10. 网页爬虫 - Python爬虫返回状态码与实际情况不符?
排行榜