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
2. Remove the string to list and list to string operations in Solution 1. Directly replace
# 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!