How to convert python characters to lowercase

silencement
Release: 2019-05-25 16:20:08
Original
4473 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template