Implementation Method and Usage Explanation of lower Function in python
- 2021-08-31 08:47:08
- OfStack
This site previously described the use of the upper function (upper function) that converts lowercase characters of strings to uppercase in python. There is a need to convert lowercase to uppercase, and there are also cases of converting uppercase to lowercase. This article mainly introduces the lower function which can convert string uppercase to lowercase letters in python.
1. lower ()
Converts all uppercase characters in a string to lowercase
2. Grammar
str.lower() -> str
3. Return value
Returns a string that converts all uppercase letters in the string to lowercase letters
4. Use examples
#!/usr/bin/python3
str = "ABCDEFG"
print( str.lower() )
Output
abcdefg
The above is the introduction of lower function in python. If you need to change the uppercase of a string to lowercase, you can use lower function
lower Function Example
# Realization lower
def my_lower(string):
if not string:
return None
lst = list(string)
for index,item in enumerate(lst):# List numbers and subscripts at the same time
ascii_index = ord(item)
if 65 <= ascii_index <= 90:
s = chr(ascii_index+32)
lst[index] = s
return ''.join(lst)
if __name__ == '__main__':
print(my_lower("2345ZRdV"))