文章详情页
Python字符串转大小写问题
问题描述
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 - scrapy-redis爬虫运行是连接redis数据库连接错误2. python 中的类变量3. python - Flask内如何跳转至其他页面。4. 怎样用python给mp3添加封面?5. js怎样实现在类似qq的联系人分组中进行搜索后,又可恢复原分组的界面?6. python - django 按日归档统计订单求解7. python - 如何将文本文件的CR换行符换成LF换行符?8. 【python小白】 问关于之初始化一次对象的问题9. Python中如何将爬取到的数据循环存入到csv文件中?10. python3.x - Python3 socket sendall出现10057
排行榜