isalpha output error

ecit04 注册会员
2023-02-28 18:15

isalpha() function is used to check if the string contains only alphanumenical characters(a-z and A-Z), and returns False if the string contains non-alphanumenical characters, and True otherwise.

Unicode is the standard used to represent character sets in Python. Unicode defines a large character set that contains almost all the characters in the world, including Chinese characters. So, if you call isalpha() in Python with a string containing Chinese characters, it will return True.

So, print(' spicy '.isalpha()) prints True correctly because Chinese characters are also considered alphabetic characters.