如何在 Python 中小写字符串? [英] How do I lowercase a string in Python?
本文介绍了如何在 Python 中小写字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法将字符串从大写,甚至部分大写转换为小写?
Is there a way to convert a string from uppercase, or even part uppercase to lowercase?
例如,公里"→公里".
For example, "Kilometers" → "kilometers".
推荐答案
使用 .lower()
- 例如:
s = "Kilometer"
print(s.lower())
官方 2.x 文档在这里:str.lower()
官方 3.x 文档在这里:str.lower()
The official 2.x documentation is here: str.lower()
The official 3.x documentation is here: str.lower()
这篇关于如何在 Python 中小写字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文