Hàm ljust[] trong Python
Hàm lstrip[] trong Python
Hàm lower[] trong Python chuyển đối tất cả chữ hoa trong chuỗi sang kiểu chữ thường.
Nội dung chính
- Cú pháp
- Ví dụ hàm lower[] trong Python
Cú pháp
Cú pháp của lower[] trong Python:
str.lower[]
Ví dụ hàm lower[] trong Python
Ví dụ sau minh họa cách sử dụng của hàm lower[] trong Python.
str1 = "Vi Du Ham lower[] Trong Python"; print [str1.lower[]]
Chạy chương trình Python trên sẽ cho kết quả −
Output:
vi du ham lower[] trong python
Hàm ljust[] trong Python
Hàm lstrip[] trong Python
The lower[]
method converts all uppercase characters in a string into lowercase characters and returns it.
Nội dung chính
- Syntax of String lower[]
- lower[] Parameters[]
- lower[] Return value
- Example 1: Convert a string to lowercase
- Example 2: How lower[] is used in a program?
- Ví dụ hàm lower[] trong Python
- Phương thức Lower[] trong Python là gì
- Cú pháp Phương thức Lower[] trong Python
- Chương trình mẫu sử dụng Phương thức Lower[] trong Python
- Lưu ý khi sử dụng Phương thức Lower[] trong Python
- Tổng kết
Example
message = 'PYTHON IS FUN'
# convert message to lowercase
print[message.lower[]]
# Output: python is fun
Syntax of String lower[]
The syntax of lower[]
method is:
string.lower[]
lower[] Parameters[]
lower[]
method doesn't take any parameters.
lower[] Return value
lower[]
method returns the lowercase string from the given string. It converts all uppercase characters to lowercase.
If no uppercase characters exist, it returns the original string.
Example 1: Convert a string to lowercase
# example string
string = "THIS SHOULD BE LOWERCASE!"
print[string.lower[]]
# string with numbers
# all alphabets should be lowercase
string = "Th!s Sh0uLd B3 L0w3rCas3!"
print[string.lower[]]
Output
this should be lowercase! th!s sh0uld b3 l0w3rcas3!
Example 2: How lower[] is used in a program?
# first string
firstString = "PYTHON IS AWESOME!"
# second string
secondString = "PyThOn Is AwEsOmE!"
if[firstString.lower[] == secondString.lower[]]:
print["The strings are same."]
else:
print["The strings are not same."]
Output
The strings are same.
Note: If you want to convert to uppercase string, use upper[]. You can also use swapcase[] to swap between lowercase to uppercase.
Hàm ljust[] trong Python
Hàm lstrip[] trong Python
Hàm lower[] trong Python chuyển đối tất cả chữ hoa trong chuỗi sang kiểu chữ thường.
Nội dung chính
- Cú pháp
- Ví dụ hàm lower[] trong Python
Cú pháp
Cú pháp của lower[] trong Python:
str.lower[]
Ví dụ hàm lower[] trong Python
Ví dụ sau minh họa cách sử dụng của hàm lower[] trong Python.
str1 = "Vi Du Ham lower[] Trong Python"; print [str1.lower[]]
Chạy chương trình Python trên sẽ cho kết quả −
Output:
vi du ham lower[] trong python
Hàm ljust[] trong Python
Hàm lstrip[] trong Python
Bài viết liên quan
Cắt chuỗi trong python [slice string python]
Cách sử dụng chuỗi thô raw string trong python
Căn trái, căn giữa và căn phải một chuỗi trong Python [ljust, center, rjust, zfill]
Ký tự đặc biệt trong python [escape sequence]
Phương thức capitalize[] trong Python
Phương thức Center[] trong Python
Chuyển chữ hoa thành chữ thường và ngược lại trong python