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://www.codercto.com/courses/l/8.html

查看所有标签

Learning Web Design

Learning Web Design

Jennifer Niederst Robbins / O'Reilly Media / 2007-6-15 / USD 44.99

Since the last edition of this book appeared three years ago, there has been a major climate change with regard to web standards. Designers are no longer using (X)HTML as a design tool, but as a means......一起来看看 《Learning Web Design》 这本书的介绍吧!

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

多种字符组合密码

MD5 加密
MD5 加密

MD5 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具