#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)
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
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!