Home > Backend Development > Python Tutorial > How to ignore case in python

How to ignore case in python

爱喝马黛茶的安东尼
Release: 2019-06-22 14:59:26
Original
9498 people have browsed it

How to ignore case in python

#How to ignore case in python? Here are two methods for you:

1. Regular expression, use IGNORECASE flag

>>> import re
>>> m = re.search('multi', 'A mUltiCased string', re.IGNORECASE)
>>> bool(m)
Copy after login

Related recommendations:《 Python video tutorial

2. Convert the two strings to the same uppercase before comparison, use the upper() method, or lowercase, lower()

>>> s = 'A mUltiCased string'.lower()
>>> s
'a multicased string'
>>> s.find('multi')
2
Copy after login

The above is the detailed content of How to ignore case in python. 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