Home >Backend Development >Python Tutorial >How to convert python characters to lowercase

How to convert python characters to lowercase

silencement
silencementOriginal
2019-05-25 11:33:134545browse

How to convert python characters to lowercase

1. First, convert the string into a list. Then the for loop determines the elements in the list and takes corresponding processing operations. Finally the list is converted back to string output. The methods used are list(str) ord() chr() "".join()

ord() function: chr() function (for 8-bit ASCII characters String) or the unichr() function (for Unicode objects), which takes a character (a string of length 1) as an argument and returns the corresponding ASCII value, or Unicode value if the given Unicode character exceeds your Python defines the range, a TypeError exception will be raised

chr(): Use an integer in the range (256) (that is, 0 ~ 255) as a parameter, and return a corresponding character

How to convert python characters to lowercase

2. Remove the string to list and list to string operations in Solution 1. Directly replace

How to convert python characters to lowercase

# with another new string

The above is the detailed content of How to convert python characters to lowercase. 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