Python isalnum()方法
Python isalnum()方法
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
相關(guān)文章
- Python 操作 MySQL 數(shù)據(jù)庫
- Python 網(wǎng)絡(luò)編程
- Python Deque
- Python 回溯
- Python3 內(nèi)置函數(shù)
- Python abs() 函數(shù)
- Python pow() 函數(shù)
- Python seed() 函數(shù)
- Python os.chflags() 方法
- Python os.fchmod() 方法
- Python os.tmpfile() 方法
- Python capitalize()方法
- Python decode()方法
- Python isalnum()方法
- Python rpartition() 方法
- Python 字典 Dictionary cmp()方法
- Python 字典 Dictionary popitem() 方法
- Python Tuple 元組 cmp()方法
- Python time strptime()方法
- Python time tzset()方法