String Manipulation

判断是否为字母, 数字 isalnum() isalpha() isnumeric()

Syntax

1
2
3
4
5
# 判断是否整个string都由alpha and numbers 组成
str.isalnum()

# 判断是否整个string
str.isalpha()

Return Type

Boolean

Ex:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# No space in string
>>> str = "this2018"
>>> str.isalnum()
True

# Space in string
>>> str = "this is..."
>>> str.isalnum()
False

# Check isalpha()
>>> str = "this2018"
>>> str.isalpha()
False