Python isalnum()方法

Python 教程 · 2019-02-02 11:57:17

描述

Python isalnum() 方法检测字符串是否由字母和数字组成。

语法

isalnum()方法语法:

str.isalnum()

参数

  • 无。

返回值

如果 string 至少有一个字符并且所有字符都是字母或数字则返回 True,否则返回 False

实例

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

实例(Python 2.0+)

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

以上实例输出结果如下:

True
False

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

More Eric Meyer on CSS (Voices That Matter)

More Eric Meyer on CSS (Voices That Matter)

Eric A. Meyer / New Riders Press / 2004-04-08 / USD 45.00

Ready to commit to using more CSS on your sites? If you are a hands-on learner who has been toying with CSS and want to experiment with real-world projects that will enable you to see how CSS......一起来看看 《More Eric Meyer on CSS (Voices That Matter)》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

在线进制转换器
在线进制转换器

各进制数互转换器

随机密码生成器
随机密码生成器

多种字符组合密码