Home  >  Article  >  Backend Development  >  Uppercase to lowercase function in python

Uppercase to lowercase function in python

小老鼠
小老鼠Original
2024-03-25 13:56:311363browse

In Python, the lower() function converts uppercase letters in a string to lowercase. This function does not alter the original string, but returns a new string in which all uppercase letters have been converted to lowercase. It is a built-in method of a string object and can be called directly on the string. For example, convert "HELLO WORLD" to "hello world":

Uppercase to lowercase function in python

In Python, you can use the lower() function to convert uppercase letters in a string are lowercase letters. The following is the basic usage of the lower() function:

# 将字符串中的大写字母转换为小写字母
string = "HELLO WORLD"
lower_string = string.lower()
print(lower_string)  # 输出:hello world

In this example, the lower() function converts the uppercase letters in the string "HELLO WORLD" to lowercase letters and stores the result in the lower_string variable .

The lower() function is a built-in method of the string object. It can be called directly on the string. It does not change the original string, but returns a new string in which all uppercase letters are replaced. Convert to lowercase letters.

In general, the lower() function is a common method in Python for converting uppercase letters in a string to lowercase letters.

The above is the detailed content of Uppercase to lowercase function in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn