📜  Python String isalnum() 方法

📅  最后修改于: 2022-05-13 01:54:26.731000             🧑  作者: Mango

Python String isalnum() 方法

Python String isalnum()方法检查给定字符串中的所有字符是否都是字母数字。字母数字表示字母或数字的字符。

示例 1:isalnum() 的工作

Python
# Python program to demonstrate the use of
# isalnum() method  
  
# here a,b and c are characters and 1,2 and 3
# are numbers
string = "abc123"
print(string.isalnum())
  
# here a,b and c are characters and 1,2 and 3 
# are numbers but space is not a alphanumeric 
# character
string = "abc 123" 
print(string.isalnum())


输出:

True
False