📜  Python 将字符串转换为小写 - Python (1)

📅  最后修改于: 2023-12-03 15:19:09.357000             🧑  作者: Mango

Python 将字符串转换为小写 - Python

在Python中,可以使用lower()函数将字符串转换为小写形式。

语法
str.lower()
参数

返回值

返回转换为小写的字符串。

示例
# 将字符串转换为小写
s = "Hello, world!"
s = s.lower()
print(s)  # 输出 hello, world!
注意事项
  • lower()函数只转换字符串中的字母,其他字符不会受影响。
  • lower()函数是字符串类型的一个内置方法,使用时直接调用即可。

以上是Python中将字符串转换为小写的方法介绍,希望对您有所帮助。