Python isalnum()方法

Python isalnum()方法

Python 字符串Python 字符串

Python isalnum() 方法檢測字符串是否由字母和數(shù)字組成。

 

語法

isalnum()方法語法:

str.isalnum()

 

參數(shù)

  • 無。

 

返回值

如果 string 至少有一個字符并且所有字符都是字母或數(shù)字則返回 True,否則返回 False

 

實例

以下實例展示了isalnum()方法的實例:

#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
str = "this2009";  # 字符中沒有空格
print str.isalnum();
 
str = "this is string example....wow/b64/";
print str.isalnum();

以上實例輸出結(jié)果如下:

True
False

Python 字符串Python 字符串

下一節(jié):Python isalpha()方法

Python 教程

相關(guān)文章
亚洲国产精品第一区二区,久久免费视频77,99V久久综合狠狠综合久久,国产免费久久九九免费视频